@import url("https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;1,400&family=IM+Fell+English:ital@0;1&family=Trirong:ital,wght@0,400;0,500;1,400&display=swap");

:root {
  --bg: #e8efe2;
  --text: #1f2a20;
  --muted: #55664f;
  --line: #b5c6a9;
  --accent: #2f5a39;
  --card: #f0f5eb;
  /* Latin glyphs come from the first font; Thai characters fall through to Trirong */
  --body-font: "EB Garamond", Garamond, "Trirong", Georgia, "Times New Roman", serif;
  --display-font: "IM Fell English", "EB Garamond", "Trirong", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151b16;
    --text: #dfe8d8;
    --muted: #97a790;
    --line: #34443a;
    --accent: #a9c99a;
    --card: #1b231d;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 20px/1.7 var(--body-font);
  font-variant-numeric: oldstyle-nums;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.wrap { max-width: 680px; margin: 0 auto; padding: 0 20px; }

nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 28px 0 16px;
  border-bottom: 3px double var(--line);
}
nav .name { font-family: var(--display-font); font-size: 22px; color: var(--text); text-decoration: none; }
nav ul { display: flex; gap: 24px; list-style: none; margin: 0; padding: 0; }
nav ul a {
  color: var(--muted);
  text-decoration: none;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-size: 19px;
}
nav ul a:hover { color: var(--accent); }

header { padding: 72px 0 48px; text-align: center; }
h1 {
  font-family: var(--display-font);
  font-weight: 400;
  font-size: clamp(36px, 7vw, 56px);
  line-height: 1.15;
  margin: 0 0 24px;
}
h1 em { color: var(--accent); }
.lead { font-size: 22px; font-style: italic; color: var(--muted); max-width: 30em; margin: 0 auto; }

/* fleuron between sections, like a chapter break */
section { padding: 24px 0 40px; }
section::before {
  content: "· · ·";
  display: block;
  text-align: center;
  color: var(--accent);
  font-size: 26px;
  margin-bottom: 24px;
}
h2 {
  font-family: var(--display-font);
  font-weight: 400;
  font-size: 30px;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--text);
  margin: 0 0 28px;
}
section > p, article p { text-align: justify; hyphens: auto; }

/* drop cap on the opening paragraph */
#about > p:first-of-type::first-letter,
article p:first-of-type::first-letter {
  float: left;
  font-family: var(--display-font);
  font-size: 3.6em;
  line-height: 0.85;
  padding: 6px 10px 0 0;
  color: var(--accent);
}

/* post list styled like a table of contents */
.projects { display: grid; gap: 0; }
.project {
  display: block;
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  transition: color .15s;
}
.projects .project:first-child { border-top: 1px solid var(--line); }
.project:hover h3 { color: var(--accent); }
.project h3 { margin: 0 0 2px; font-family: var(--display-font); font-weight: 400; font-size: 24px; }
.project p { margin: 0; color: var(--muted); font-style: italic; }
.tags { margin-top: 6px; font-size: 16px; font-variant: small-caps; letter-spacing: 0.06em; color: var(--accent); }

/* contact: label ..... value, like a table of contents */
.contact { margin: 0 auto; max-width: 520px; }
.contact div { display: flex; align-items: baseline; padding: 6px 0; }
.contact dt {
  flex: 1;
  display: flex;
  align-items: baseline;
  font-variant: small-caps;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.contact dt::after { content: ""; flex: 1; min-width: 24px; margin: 0 12px; border-bottom: 1px dotted var(--line); }
.contact dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }

footer {
  padding: 32px 0 56px;
  color: var(--muted);
  font-size: 17px;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  text-align: center;
  border-top: 3px double var(--line);
}

/* home: main column + blog/library preview block on the right */
.wrap.home { max-width: 1080px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 56px; align-items: start; }
.sidebar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 24px 4px;
  margin: 24px 0 56px;
}
.sidebar section { padding: 16px 0 20px; }
.sidebar section::before { margin-bottom: 12px; }
.sidebar h2 { font-size: 26px; margin-bottom: 16px; }
.sidebar section > p { text-align: left; font-size: 18px; }
.sidebar .project { padding: 12px 2px; }
.sidebar .project h3 { font-size: 20px; }
.sidebar .project p { font-size: 17px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

[hidden] { display: none !important; }

/* live "Now" block (status.js) */
.status { margin: 0 0 14px; font-variant: small-caps; letter-spacing: 0.06em; color: var(--muted); }
.status::before {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: 0.1em;
  background: var(--muted);
}
.status[data-state="online"]::before { background: #3ba55d; }
.status[data-state="idle"]::before { background: #e3a21a; }
.status[data-state="dnd"]::before { background: #d9403a; }
.track { display: flex; gap: 14px; align-items: center; }
.track img { width: 64px; height: 64px; border-radius: 4px; object-fit: cover; flex: none; border: 1px solid var(--line); }
.track div { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.track .label { font-size: 14px; font-variant: small-caps; letter-spacing: 0.06em; color: var(--muted); }
.track .song, .track .artist { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track .song { font-family: var(--display-font); font-size: 19px; }
.track .song:not([href]) { color: var(--text); }
.track .artist { font-size: 16px; font-style: italic; color: var(--muted); }
.idle { color: var(--muted); font-style: italic; }

/* Thai: no spaces between words, stacked vowel/tone marks, no small caps */
:lang(th) { letter-spacing: normal; font-variant: normal; line-height: 1.85; }
:lang(th) h1 { line-height: 1.45; }
:lang(th) h2, :lang(th) .project h3 { line-height: 1.5; }
section > p:lang(th), article p:lang(th) { text-align: left; }
#about > p:lang(th):first-of-type::first-letter,
article p:lang(th):first-of-type::first-letter {
  float: none; font: inherit; padding: 0; color: inherit;
}

@media (max-width: 520px) {
  nav { flex-direction: column; align-items: center; gap: 8px; }
  header { padding: 40px 0 32px; }
  section > p, article p { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .project { transition: none; }
}
