/* ───────── Fonts ───────── */
@font-face {
  font-family: "Perfectly Nineties";
  src: url("fonts/PerfectlyNineties-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face { font-family: "Neue Rain"; src: url("fonts/NeueRain-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Neue Rain"; src: url("fonts/NeueRain-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Neue Rain"; src: url("fonts/NeueRain-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

/* ───────── Tokens ───────── */
:root {
  --bg: #1f0405;
  --wine: #3a0d10;
  --rose: #7c2d33;
  --rose-soft: #a65a5c;
  --line: rgba(196, 128, 120, .45);
  --cream: #f4ece2;
  --cream-dim: rgba(244, 236, 226, 0.66);
  --cream-faint: rgba(244, 236, 226, 0.16);
  --paper: #ece3d6;
  --ink: #1e0607;

  /* Perfectly Nineties for every serif; Noto Serif Thai only fills in Thai glyphs */
  --f-head: "Perfectly Nineties", "Noto Serif Thai", serif;
  --f-body: "Neue Rain", "Noto Sans Thai", -apple-system, "Helvetica Neue", sans-serif;

  --gutter: 24px;
  --speech-size: 20px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--f-body);
  font-weight: 300;
  line-height: 1.5;
  font-synthesis: none; /* no fake italics/bolds — Perfectly Nineties ships one weight */
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 1.5px solid var(--cream); outline-offset: 4px; border-radius: 4px; }

.sheen {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  /* satin backdrop: solid wine at the top, silk showing through towards the bottom */
  background:
    linear-gradient(to bottom, rgba(31,4,5,1) 0%, rgba(31,4,5,.9) 35%, rgba(31,4,5,.25) 100%),
    url("images/silk.webp") 70% 100% / cover no-repeat,
    var(--bg);
}
/* keep the silk much quieter behind long-form reading */
body[data-view="speech"] .sheen {
  background:
    linear-gradient(to bottom, rgba(31,4,5,1) 0%, rgba(31,4,5,.95) 50%, rgba(31,4,5,.82) 100%),
    url("images/silk.webp") 70% 100% / cover no-repeat,
    var(--bg);
}

.app {
  position: relative; z-index: 1;
  max-width: 480px; /* mobile-only: phone-width column, no desktop layout */
  margin: 0 auto;
  min-height: 100svh;
  padding: 0 var(--gutter);
}

.view { animation: rise .7s var(--ease) backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ───────── Shared ───────── */
.display { font-family: var(--f-head); font-weight: 400; line-height: 1; letter-spacing: -0.01em; margin: 0; }
.display em { font-style: normal; color: var(--rose-soft); }

.logo { display: block; height: 32px; width: auto; }

/* top bar: round back button + centred logo */
.topbar {
  position: sticky; top: 0; z-index: 10;
  margin: 0 calc(var(--gutter) * -1);
  padding: max(20px, env(safe-area-inset-top)) var(--gutter) 12px;
  display: grid; grid-template-columns: 48px 1fr 48px; align-items: center;
  transition: background .3s, border-color .3s;
  border-bottom: 1px solid transparent;
}
.topbar .logo { justify-self: center; }
.topbar.scrolled {
  background: rgba(26, 4, 5, .84);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom-color: var(--cream-faint);
}
.round-btn {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(244, 236, 226, .08);
  border: 1px solid var(--line);
  box-shadow: 0 6px 18px -6px rgba(0,0,0,.6);
  transition: background .3s;
}
.round-btn:active { background: rgba(244, 236, 226, .18); }
.round-btn svg { width: 20px; height: 20px; }

.home-head { display: flex; align-items: center; justify-content: center; height: 48px; box-sizing: content-box; padding: max(20px, env(safe-area-inset-top)) 0 12px; }

.divider { display: flex; justify-content: center; margin: 44px 0 0; }
.divider img { width: 176px; height: auto; opacity: .9; }

/* ───────── Polaroids ───────── */
.polaroid {
  --rot: 0deg;
  display: block; margin: 0;
  background: var(--paper);
  padding: 9px 9px 0;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 18px 30px -12px rgba(0,0,0,.65), 0 4px 10px rgba(0,0,0,.35);
  transform: rotate(var(--rot));
  transition: transform .5s var(--ease);
}
.polaroid .photo { aspect-ratio: 5 / 6; overflow: hidden; background: var(--wine); }
.polaroid .photo img { width: 100%; height: 100%; object-fit: cover; }
.polaroid figcaption {
  font-family: var(--f-head); color: var(--ink); text-align: center;
  font-size: 24px; line-height: 1; padding: 12px 4px 15px;
}
a.polaroid:active { transform: rotate(var(--rot)) scale(.97); }

/* ───────── Home ───────── */
.home-hero { padding: 26px 0 32px; text-align: center; }
.home-hero .display { font-size: clamp(32px, 9.6vw, 42px); line-height: 1.12; max-width: 12em; margin: 0 auto; }

.speakers {
  list-style: none; margin: 0; padding: 0 0 calc(48px + var(--safe-b));
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px 14px;
}
.speakers .polaroid { padding: 8px 8px 0; border-radius: 4px; }
.speakers .polaroid .photo { border-radius: 3px; }
.speakers .polaroid figcaption { font-size: 22px; padding: 14px 4px 16px; }
/* slightly different paper stocks + small tilts, like a loose stack of prints */
.speakers li:nth-child(5n+1) .polaroid { --rot: -1.2deg; background: #f3efe5; }
.speakers li:nth-child(5n+2) .polaroid { --rot: 1deg;    background: #dedbd1; }
.speakers li:nth-child(5n+3) .polaroid { --rot: -0.8deg; background: #d9d9d6; }
.speakers li:nth-child(5n+4) .polaroid { --rot: 0.8deg;  background: #f1eee6; }
.speakers li:nth-child(5n)   .polaroid { --rot: 1.2deg;  background: #dfdcd2; }
.speakers .role { display: block; font-family: var(--f-body); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: rgba(30,6,7,.6); margin-top: 6px; }

/* ───────── Language ───────── */
.lang-intro { text-align: center; padding: 4px 0 22px; }
.lang-intro .polaroid { --rot: -3deg; width: 84px; margin: 0 auto 16px; padding: 5px 5px 0; }
.lang-intro .polaroid figcaption { font-size: 15px; padding: 6px 2px 8px; }
.lang-intro .display { font-size: clamp(34px, 10vw, 42px); }
.lang-intro p { margin: 10px 0 0; font-size: 16px; font-weight: 400; letter-spacing: .01em; color: rgba(244, 236, 226, .8); }

.lang-list { list-style: none; margin: 0; padding: 0 0 calc(48px + var(--safe-b)); display: grid; gap: 14px; }
.lang-card {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center;
  min-height: 92px; padding: 0 26px 0 28px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(40, 6, 8, .55);
  box-shadow: 0 10px 24px -14px rgba(0,0,0,.8);
  transition: background .3s, transform .2s var(--ease);
}
.lang-card:active { transform: scale(.985); background: rgba(124, 45, 51, .35); }
.lang-card .code { font-family: var(--f-head); font-size: 15px; letter-spacing: .2em; }
.lang-card .name { font-family: var(--f-head); font-size: 32px; line-height: 1; }
.lang-card .name:lang(th) { font-family: "Noto Serif Thai", serif; font-size: 27px; }
.lang-card svg { width: 26px; height: 26px; }

/* ───────── Speech ───────── */
.speech-hero { text-align: center; padding: 26px 0 40px; }
.speech-hero .display { font-size: clamp(46px, 14vw, 62px); line-height: 1.02; }
.speech-hero .display:lang(th) { font-size: clamp(36px, 11vw, 48px); line-height: 1.25; }

.seg { display: inline-flex; margin-top: 22px; border: 1px solid var(--cream-faint); border-radius: 999px; padding: 3px; background: rgba(0,0,0,.18); }
.seg a {
  min-width: 42px; height: 30px; padding: 0 8px;
  display: grid; place-items: center; border-radius: 999px;
  font-size: 11px; letter-spacing: .14em; font-weight: 400; color: var(--cream-dim);
  transition: background .3s, color .3s;
}
.seg a[aria-current="true"] { background: var(--cream); color: var(--ink); }

.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; }
.progress i { display: block; height: 100%; width: 0; background: var(--rose-soft); transition: width .1s linear; }

.speech {
  font-size: var(--speech-size);
  /* readability for older guests: regular (not light) weight, a touch of tracking
     and word spacing, comfortable leading */
  line-height: 1.2;
  font-weight: 400;
  letter-spacing: 0.012em;
  word-spacing: 0.04em;
  color: var(--cream);
  overflow-wrap: break-word;
}
.speech p { margin: 0 0 1.25em; }
.speech p:last-child { margin-bottom: 0; }
.speech.has-dropcap p:first-of-type { display: flow-root; }
.speech.has-dropcap p:first-of-type::first-letter {
  font-family: var(--f-head);
  float: left; font-size: 3.1em; line-height: .84;
  padding: .06em .08em 0 0; color: var(--rose-soft);
}
.speech:lang(th) { line-height: 1.5; letter-spacing: 0; word-spacing: 0.08em; }
.speech:lang(th).has-dropcap p:first-of-type::first-letter { all: unset; }
.btn:lang(th) { letter-spacing: 0; text-transform: none; font-size: 15px; }
.speech-end { text-align: center; padding: 64px 0 calc(130px + var(--safe-b)); }

/* fade the text out behind the dock, like the mock */
.fade-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(120px + var(--safe-b));
  z-index: 15; pointer-events: none;
  background: linear-gradient(to bottom, rgba(31,4,5,0), rgba(31,4,5,.92) 70%);
}

/* font-size dock */
.dock {
  position: fixed; z-index: 20;
  left: 50%; bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 432px);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(52, 12, 15, .9);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(196, 128, 120, .3);
  box-shadow: 0 16px 40px -10px rgba(0,0,0,.7);
  transition: transform .45s var(--ease), opacity .45s var(--ease);
}
.dock.hide { transform: translate(-50%, 140%); opacity: 0; }
.dock .a { font-family: var(--f-head); line-height: 1; color: var(--cream); user-select: none; min-width: 32px; min-height: 40px; }
.dock .a.sm { font-size: 16px; }
.dock .a.lg { font-size: 28px; }

input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 8px rgba(244,236,226,.28); }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 36px; background: transparent; margin: 0;
  --pct: 30%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; border-radius: 2px;
  background: linear-gradient(to right, var(--cream) var(--pct), rgba(244,236,226,.22) var(--pct));
}
input[type="range"]::-moz-range-track { height: 2px; background: rgba(244,236,226,.22); border-radius: 2px; }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--cream); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; margin-top: -11px; border-radius: 50%;
  background: var(--cream); border: 0;
  box-shadow: 0 0 0 6px rgba(244,236,226,.12), 0 2px 8px rgba(0,0,0,.4);
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: var(--cream); border: 0;
  box-shadow: 0 0 0 6px rgba(244,236,226,.12), 0 2px 8px rgba(0,0,0,.4);
}

/* ───────── Not found ───────── */
.empty { padding: 60px 0; text-align: center; }
.empty .display { font-size: 48px; margin-bottom: 24px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 28px; border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px; letter-spacing: .2em; text-transform: uppercase; font-weight: 400;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* speaker whose speech isn't written yet */
.polaroid.is-pending { position: relative; }
.polaroid.is-pending .photo img { filter: grayscale(.6) brightness(.75); }
.pending-note {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  white-space: nowrap; padding: 7px 14px; border-radius: 999px;
  background: rgba(31, 4, 5, .78); border: 1px solid var(--line);
  font-family: var(--f-head); font-size: 16px; color: var(--cream);
}
