/* ───────────────── EDITORIAL CHESS — typographic foundation ───────────────── */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

html { -webkit-text-size-adjust: 100%; }

body {
  /* Body — Fraunces, opsz lets the type breathe at small sizes */
  font-family: "Fraunces", "Cormorant Garamond", "Georgia", serif;
  font-optical-sizing: auto;
  font-variation-settings: "opsz" 14, "SOFT" 30;
  font-weight: 400;
  font-size: 15.5px;
  line-height: 1.55;
  letter-spacing: -0.005em;

  background: var(--bg);
  color: var(--ink);
  position: relative;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

/* Grain — adds film-like noise; sits above bg but below content */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: var(--grain);
  background-size: 160px 160px;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: overlay;
  opacity: .85;
}

/* Subtle radial wash to add atmosphere — top-right ember in dark, warm halo in light */
body::after {
  content: "";
  position: fixed; inset: -10%;
  background:
    radial-gradient(ellipse 70% 50% at 85% 0%,  var(--accent-soft), transparent 70%),
    radial-gradient(ellipse 80% 60% at 0% 100%, var(--accent-soft), transparent 70%);
  pointer-events: none;
  z-index: 0;
  opacity: .9;
}

#app { position: relative; z-index: 1; }

button, input, textarea { font-family: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.015em; }
.hidden { display: none !important; }

/* Selection */
::selection { background: var(--accent); color: var(--surface); }

/* Layout */
.app {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 18px env(safe-area-inset-bottom);
  max-width: 580px;
  margin: 0 auto;
  position: relative;
}

.screen {
  display: none;
  padding-top: 16px;
  padding-bottom: 36px;
  animation: pageIn .42s cubic-bezier(.2,.7,.25,1) both;
}
.screen.active { display: block; }

.screen-h {
  font-family: "Fraunces", serif;
  font-variation-settings: "opsz" 90, "SOFT" 0;
  font-weight: 600;
  font-size: 38px;
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 8px 2px 4px;
  color: var(--ink);
}
.screen-h::after {
  content: ""; display: block;
  width: 42px; height: 2px;
  background: var(--accent);
  margin: 14px 0 22px 2px;
}

/* Kicker — small caps roman-numeral label above each screen heading */
.kicker {
  font-family: "Fraunces", serif;
  font-weight: 500;
  font-variation-settings: "opsz" 14;
  font-style: italic;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 4px 2px 4px;
  display: flex; align-items: center; gap: 10px;
}
.kicker::before, .kicker::after {
  content: ""; height: 1px; flex: 1; background: var(--rule);
}
.kicker .num {
  font-style: normal; color: var(--accent); letter-spacing: 0.1em;
  font-variation-settings: "opsz" 14, "wght" 700;
}

/* Animations */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(10px) scale(.995); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes flicker {
  0%, 100% { opacity: 1; }
  47%, 51% { opacity: .6; }
}

/* ───── Topbar ───── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0 14px;
  background: linear-gradient(var(--bg) 75%, transparent);
  backdrop-filter: blur(6px);
}
.topbar-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  border-radius: 0;
  transition: transform .15s ease, color .15s, border-color .15s, background .15s;
}
.topbar-btn:hover { color: var(--accent); border-color: var(--rule-strong); }
.topbar-btn:active { transform: scale(.92); }
.topbar-title {
  flex: 1; text-align: center;
  font-family: "Fraunces", serif;
  font-variation-settings: "opsz" 36;
  font-weight: 500; font-size: 17px;
  letter-spacing: 0.005em;
}

/* ───── Toast ───── */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120px);
  background: var(--surface); color: var(--ink);
  padding: 12px 18px; border-radius: 0;
  border: 1px solid var(--rule-strong);
  border-top: 2px solid var(--accent);
  font-family: "Fraunces", serif;
  font-size: 14px; font-style: italic;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  pointer-events: none; opacity: 0;
  transition: transform .35s cubic-bezier(.2,.7,.25,1), opacity .25s ease;
  z-index: 200; max-width: 88vw; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ───── Overlay / Modal ───── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(8, 6, 4, .68);
  display: grid; place-items: center;
  z-index: 300;
  animation: fadeIn .25s ease both;
  padding: 24px;
}
.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  padding: 28px 26px 24px;
  max-width: 380px; width: 100%;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  animation: pageIn .35s ease both;
}
/* corner vignettes — four tiny crosshairs */
.modal::before, .modal::after,
.invite-result::before, .invite-result::after,
.profile-card::before, .profile-card::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 1px solid var(--accent);
  pointer-events: none;
}
.modal::before        { top: 6px; left: 6px;      border-right: 0; border-bottom: 0; }
.modal::after         { bottom: 6px; right: 6px;  border-left: 0;  border-top: 0; }
.invite-result::before{ top: 6px; left: 6px;      border-right: 0; border-bottom: 0; }
.invite-result::after { bottom: 6px; right: 6px;  border-left: 0;  border-top: 0; }
.profile-card::before { top: 6px; left: 6px;      border-right: 0; border-bottom: 0; }
.profile-card::after  { bottom: 6px; right: 6px;  border-left: 0;  border-top: 0; }

.modal-title {
  font-family: "Fraunces", serif;
  font-variation-settings: "opsz" 60;
  font-weight: 600; font-size: 22px;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.modal-body { font-size: 14px; color: var(--ink-dim); margin-bottom: 22px; line-height: 1.55; }
.modal-body em { color: var(--ink); font-style: italic; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ───── Splash ───── */
.splash {
  position: fixed; inset: 0;
  display: grid; place-items: center; align-content: center;
  gap: 16px;
  background: var(--bg);
  z-index: 100;
  padding: 40px 20px;
}
.splash.active { display: grid; }
.splash:not(.active) { display: none; }
.splash-logo svg {
  filter: drop-shadow(0 18px 40px rgba(0,0,0,.55));
}
.splash-title {
  font-family: "Fraunces", serif;
  font-variation-settings: "opsz" 144, "SOFT" 0;
  font-weight: 600; font-size: 44px;
  letter-spacing: -0.04em;
  line-height: .95;
  text-align: center;
}
.splash-title em {
  font-style: italic; color: var(--accent);
  font-variation-settings: "opsz" 144, "SOFT" 50;
}
.splash-sub {
  font-family: "Fraunces", serif;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: -8px;
}
.splash-sub::before, .splash-sub::after {
  content: "·"; margin: 0 8px; color: var(--accent);
}
.splash-spinner { display: flex; gap: 6px; margin-top: 4px; }
.splash-spinner div {
  width: 6px; height: 6px; border-radius: 0;
  background: var(--accent);
  animation: dotbounce 1.5s ease-in-out infinite;
}
.splash-spinner div:nth-child(2) { animation-delay: .15s; }
.splash-spinner div:nth-child(3) { animation-delay: .30s; }
@keyframes dotbounce {
  0%, 80%, 100% { transform: scale(.45); opacity: .35; }
  40% { transform: scale(1); opacity: 1; }
}
