/* ยอด / YOT — samut-khoi manuscript page. Theme swaps ride body[data-time]. */
:root {
  --paper: #f3e7c9;
  --wash-a: #faf1d9;
  --wash-b: #efe1bd;
  --ink: #2b2013;
  --ink-soft: #8a7a58;
  --vermilion: #a3341f;
  --gold: #9a7514;
  --rule: rgba(70, 50, 20, 0.35);
  --hairline: rgba(70, 50, 20, 0.18);
  --grid: rgba(96, 74, 32, 0.055);
  --track: #ddcda4;
  --fill: var(--vermilion);
  --thai: "Noto Serif Thai", "Sathu", "Thonburi", serif;
  --sans: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
}
body[data-time="sunset"] {
  --paper: #f0dcb4; --wash-a: #f8e6bd; --wash-b: #eacf9f;
  --ink: #33210f; --ink-soft: #96794c; --vermilion: #9c2f1a;
  --track: #dcc394;
}
body[data-time="night"] {
  --paper: #191c26; --wash-a: #232735; --wash-b: #14161f;
  --ink: #e8e2cd; --ink-soft: #8d8770; --vermilion: #d9764a;
  --gold: #d1a942;
  --rule: rgba(232, 226, 205, 0.35); --hairline: rgba(232, 226, 205, 0.16);
  --grid: rgba(232, 226, 205, 0.04);
  --track: #333a4e; --fill: #d9764a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
body, .brand, .plaque, .stage, .pct, .foot, .rulewrap {
  transition: background-color 0.55s ease, color 0.55s ease, border-color 0.55s ease;
}

#app { position: fixed; inset: 0; }

.bg-wash {
  position: absolute; inset: 0;
  background: radial-gradient(120% 85% at 50% 42%,
    var(--wash-a) 0%, var(--wash-a) 30%, var(--paper) 62%, var(--wash-b) 100%);
  transition: background 0.55s ease;
}
.bg-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 88px 88px;
}

#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- editorial chrome ---------- */
.chrome { position: absolute; inset: 0; pointer-events: none; }
.chrome > * { pointer-events: auto; }

.brand {
  position: absolute; top: 34px; left: 42px; line-height: 0.95;
  user-select: none; pointer-events: none;
}
.brand .th {
  font-family: var(--thai);
  font-size: clamp(64px, 9vw, 128px);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand .roman {
  margin-top: 14px;
  font-size: 11px; letter-spacing: 0.42em; text-transform: uppercase;
  color: var(--ink-soft);
}

.plaque {
  position: absolute; top: 40px; right: 44px; text-align: right; pointer-events: none;
}
.plaque .th { font-family: var(--thai); font-size: clamp(26px, 3vw, 40px); font-weight: 600; }
.plaque .en {
  margin-top: 8px; font-size: 10px; letter-spacing: 0.34em; text-transform: uppercase;
  color: var(--ink-soft);
}

/* soft paper halo keeps type legible over the terrain */
.stage, .pct, .foot, .brand, .plaque {
  text-shadow: 0 0 12px var(--paper), 0 0 28px var(--paper), 0 1px 18px var(--paper);
}

.stage {
  position: absolute; left: 44px; bottom: 108px; pointer-events: none;
}
.stage .th { font-family: var(--thai); font-size: clamp(20px, 2.2vw, 30px); }
.stage .en {
  margin-top: 6px; font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--ink-soft);
}
.stage.fade { opacity: 0; }
.stage { transition: opacity 0.2s ease; }

.pct {
  position: absolute; right: 44px; bottom: 96px; pointer-events: none;
  font-size: clamp(56px, 7vw, 104px); font-weight: 200; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.pct .sym { font-size: 0.38em; font-weight: 300; color: var(--ink-soft); }

.foot {
  position: absolute; left: 44px; right: 44px; bottom: 30px;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
  display: flex; align-items: center; gap: 20px;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-soft);
}

.fbtn {
  min-width: 40px; min-height: 40px;
  background: none; border: none; cursor: pointer;
  color: var(--ink); font-size: 16px; font-family: var(--sans);
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.55s ease, opacity 0.2s ease;
}
.fbtn:hover { opacity: 0.6; }
.fbtn.off { opacity: 0.35; }

.track {
  flex: 1; height: 40px; display: flex; align-items: center; cursor: pointer;
  position: relative;
}
.track::before {
  content: ''; position: absolute; left: 0; right: 0; top: 19px; height: 2px;
  background: var(--track);
}
.fill {
  position: absolute; left: 0; top: 19px; height: 2px; width: 0%;
  background: var(--fill);
  transition: background-color 0.55s ease;
}

.pager { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.plabel {
  font-family: var(--thai); font-size: 13px; letter-spacing: 0.05em;
  text-transform: none; color: var(--ink); min-width: 150px; text-align: center;
}
button.fbtn-wide { background: none; border: none; cursor: pointer; min-height: 40px; padding: 0 8px; }
button.fbtn-wide:hover { opacity: 0.6; }
.keys { font-size: 9px; letter-spacing: 0.14em; white-space: nowrap; }

.wash {
  position: absolute; inset: 0; pointer-events: none;
  background: var(--paper); opacity: 0;
  transition: opacity 0.36s ease;
}
.wash.on { opacity: 1; }

@media (max-width: 900px) {
  .keys { display: none; }
  .brand { top: 22px; left: 22px; }
  .brand .roman { display: none; }
  .brand .th { font-size: 56px; }
  .plaque { top: 26px; right: 24px; }
  .plaque .th { font-size: 22px; }
  .stage { left: 24px; bottom: 170px; }
  .stage .th { font-size: 18px; }
  .pct { right: 24px; bottom: 158px; font-size: 46px; }
  .foot { left: 20px; right: 20px; bottom: 18px; flex-wrap: wrap; gap: 8px; }
  .plabel { min-width: 110px; font-size: 12px; }
}
