/* ─── Fonts ─────────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Garet';
  src: url('../assets/fonts/Garet-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: 'Libre Baskerville';
  src: url('../assets/fonts/LibreBaskerville-Italic.ttf') format('truetype');
  font-weight: 400;
  font-style: italic;
}

@property --shimmer-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

/* ─── Design Tokens ───────────────────────────────────────────────────────
   Type scale: 6 fixed sizes, used everywhere — no ad hoc font-sizes.
   Spacing: a 4px baseline grid. The named --sp-* stops mark the macro
   rhythm (section/group gaps); fine control padding (buttons, inputs)
   pulls other multiples of 4 directly from the same grid.
   ────────────────────────────────────────────────────────────────────── */

:root {
  /* Type scale */
  --fs-1: 10px;
  --fs-2: 11px;
  --fs-3: 12px;
  --fs-4: 13px;
  --fs-5: 14px;
  --fs-6: 16px;

  /* Spacing scale (4px baseline grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 40px;
  --sp-6: 64px;
  --sp-7: 104px;

  /* Colour */
  --navy-deep: #030612;
  --navy-panel: #0d1c45;
  --cream: #e8e0d4;
  --cream-dim: rgba(200, 191, 176, 0.65);
  --gold: #d79a3f;
  --gold-light: #e8b563;
  --gold-dark: #c8873a;
  --gold-gradient: linear-gradient(180deg, var(--gold-light) 0%, var(--gold-dark) 100%);
  --error: #d76a5a;

  /* Surfaces */
  --radius: 7px;
  --radius-sm: 6px;
  --shadow-panel: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --glow-gold: 0 0 20px rgba(215, 154, 63, 0.25);
  --ring-gold: 0 0 0 3px rgba(215, 154, 63, 0.12);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ───────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--navy-deep);
}

html {
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body {
  font-family: 'Garet', sans-serif;
  color: var(--cream);
  background-color: var(--navy-deep);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

::selection {
  background: var(--gold);
  color: var(--navy-deep);
}

/* ─── Background: Navy Radial Gradient ───────────────────────────────────── */
/* Light source: radial glow at top-center. Panel highlights, ring stroke
   and shadow direction all agree with it (see .ring, .bg-grain). */

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, #0d1c45 0%, #060e28 45%, #030612 100%);
}

/* ─── Background: Grid Pattern ───────────────────────────────────────────── */

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 1;
  background-image:
    linear-gradient(rgba(160, 180, 220, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(160, 180, 220, 0.07) 1px, transparent 1px);
  background-size: 34px 34px;
  /* Radial mask: grid strongest at center, fades toward edges */
  -webkit-mask-image: radial-gradient(ellipse 65% 55% at 50% 30%, black 0%, transparent 100%);
  mask-image: radial-gradient(ellipse 65% 55% at 50% 30%, black 0%, transparent 100%);
}

/* ─── Vignette ───────────────────────────────────────────────────────────── */

.bg-vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse 100% 100% at 50% 50%,
    transparent 40%,
    rgba(1, 3, 10, 0.55) 70%,
    rgba(1, 3, 10, 0.92) 100%);
  pointer-events: none;
}

/* ─── Grain ──────────────────────────────────────────────────────────────── */
/* Ultra-subtle film grain so the flat gradients read as atmosphere rather
   than a digital flat fill. Sits above the vignette, below the modal. */

.bg-grain {
  position: fixed;
  inset: 0;
  z-index: 3;
  opacity: 0.025;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-repeat: repeat;
  mix-blend-mode: overlay;
}

/* ─── Page Content Wrapper ───────────────────────────────────────────────── */

.page {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Focus ──────────────────────────────────────────────────────────────── */

a:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: var(--ring-gold);
  border-radius: var(--radius-sm);
}

/* ─── Top Nav ────────────────────────────────────────────────────────────── */

nav {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding: var(--sp-4) var(--sp-5) 0;
}

.nav-access,
.nav-exit {
  position: relative;
  font-family: 'Garet', sans-serif;
  font-size: var(--fs-2);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  text-decoration: none;
  opacity: 0.9;
  transition: opacity 0.2s var(--ease);
  background: none;
  border: none;
  padding: 2px 0;
  cursor: pointer;
}

.nav-access::after,
.nav-exit::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0.4);
  opacity: 0.5;
  transform-origin: center;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}

.nav-access:hover,
.nav-exit:hover {
  opacity: 1;
}

.nav-access:hover::after,
.nav-exit:hover::after {
  transform: scaleX(1);
  opacity: 1;
}

/* ─── Hero Section ───────────────────────────────────────────────────────── */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4) 0;
  width: 100%;
  flex: 1;
}

/* ─── Page-load entrance: ring, tagline, values, invite compose in ───────── */

@keyframes fade-up-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ring-wrap        { animation: fade-up-in 0.6s var(--ease) 0s   both; }
.tagline          { animation: fade-up-in 0.6s var(--ease) 0.09s both; }
.invite-section.visible,
.session-panel.visible { animation: fade-up-in 0.6s var(--ease) 0.18s both; }

@media (prefers-reduced-motion: reduce) {
  .ring-wrap,
  .tagline,
  .invite-section.visible,
  .session-panel.visible {
    animation: none;
  }
}

/* ─── Logo Ring ──────────────────────────────────────────────────────────── */

.ring-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring {
  width: 720px;
  height: 720px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-6);
  position: relative;
}

.ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  padding: 1px;
  background: linear-gradient(180deg, rgba(215, 154, 63, 0.5), rgba(160, 110, 60, 0.22));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Source logo.png has heavy transparent padding above/below the wordmark
   (glyph occupies ~19% of the canvas height); object-fit: cover crops that
   dead space so the box below matches the actual visible mark at 3x its
   old rendered size, rather than 3x-ing the empty canvas. */
.ring-logo {
  width: 312px;
  height: 90px;
  object-fit: cover;
  object-position: center;
  display: block;
  flex-shrink: 0;
}

/* ─── Tagline ────────────────────────────────────────────────────────────── */

.tagline {
  font-family: 'Garet', sans-serif;
  font-size: var(--fs-6);
  letter-spacing: 0.5px;
  color: var(--gold);
  text-align: center;
  max-width: 540px;
  line-height: 1.6;
  margin: 0;
  padding: 0 var(--sp-4);
}

.tagline .brand-white {
  color: var(--cream);
}

.tagline sup {
  font-size: 0.6em;
  vertical-align: super;
  letter-spacing: normal;
  color: var(--cream-dim);
}

/* ─── Invite Section ─────────────────────────────────────────────────────── */

.invite-section {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  max-width: 480px;
  padding: 0 var(--sp-4);
}

.invite-section.visible {
  display: flex;
}

/* ─── Active Session Panel ───────────────────────────────────────────────── */
/* Shown instead of the invite form when a valid session already exists —
   never auto-redirects, just offers Continue. Hidden by default like
   .invite-section, so neither flashes while check_session is pending. */

.session-panel {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  max-width: 480px;
  padding: var(--sp-4);
  border: 1px solid rgba(215, 154, 63, 0.35);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.015);
  box-shadow: var(--shadow-panel);
}

.session-panel.visible {
  display: flex;
}

.session-text {
  font-family: 'Libre Baskerville', serif;
  font-style: italic;
  font-size: var(--fs-5);
  line-height: 1.6;
  color: rgba(232, 224, 212, 0.85);
  text-align: center;
}

.invite-label {
  font-family: 'Garet', sans-serif;
  font-size: var(--fs-1);
  letter-spacing: 4px;
  margin-right: -4px;
  line-height: 1.1;
  text-transform: uppercase;
  color: var(--gold);
}

.invite-form {
  display: flex;
  gap: 0;
  width: 100%;
}

.invite-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(215, 154, 63, 0.45);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 12px var(--sp-3);
  font-family: 'Libre Baskerville', serif;
  font-style: italic;
  font-size: var(--fs-5);
  color: rgba(232, 224, 212, 0.85);
  caret-color: var(--gold);
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease);
  min-width: 0;
}

.invite-input::placeholder {
  color: rgba(200, 191, 176, 0.35);
}

.invite-input:focus {
  border-color: var(--gold-light);
  box-shadow: var(--ring-gold);
  background: rgba(255, 255, 255, 0.05);
}

.invite-input:-webkit-autofill,
.invite-input:-webkit-autofill:hover,
.invite-input:-webkit-autofill:focus {
  -webkit-text-fill-color: rgba(232, 224, 212, 0.85);
  -webkit-box-shadow: 0 0 0 1000px #0a1230 inset;
  transition: background-color 9999s ease-in-out 0s;
}

.invite-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Garet', sans-serif;
  font-size: var(--fs-2);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  background: transparent;
  border: 1px solid rgba(215, 154, 63, 0.45);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px var(--sp-4);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
  white-space: nowrap;
  flex-shrink: 0;
  z-index: 0;
}

.invite-btn .btn-label {
  display: inline-block;
  margin-right: -3px;
}

/* .invite-btn's base border-radius is a paired shape (square left / round
   right) meant to sit flush against .invite-input's round-left corners.
   #continueBtn stands alone in .session-panel with no input beside it, so
   it needs all four corners rounded, not the paired half-shape. */
#continueBtn {
  border-radius: var(--radius);
}

.invite-btn:hover:not(:disabled) {
  background: var(--gold-gradient);
  color: var(--navy-deep);
  border-color: var(--gold-light);
  box-shadow: var(--glow-gold);
  transform: translateY(-1px);
}

.invite-btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 0 8px rgba(215, 154, 63, 0.18);
}

.invite-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.invite-btn.is-loading {
  color: rgba(215, 154, 63, 0.6);
}

.invite-btn.is-loading::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: conic-gradient(from var(--shimmer-angle), transparent 0%, var(--gold-light) 35%, transparent 65%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: shimmer-rotate 1.3s linear infinite;
  z-index: -1;
}

@keyframes shimmer-rotate {
  to { --shimmer-angle: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
  .invite-btn.is-loading::before {
    animation: none;
  }
}

/* ─── Status Message ─────────────────────────────────────────────────────── */

.status-msg {
  font-family: 'Garet', sans-serif;
  font-size: var(--fs-2);
  letter-spacing: 1.5px;
  margin-right: -1.5px;
  text-align: center;
  display: none;
  opacity: 0;
  min-height: 1em;
}

.status-msg.visible {
  display: block;
  animation: fade-in-msg 0.3s var(--ease) forwards;
}

@keyframes fade-in-msg {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.status-msg.error {
  color: var(--error);
}

.status-msg.info {
  color: rgba(200, 191, 176, 0.65);
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */

footer {
  width: 100%;
  border-top: 1px solid rgba(200, 191, 176, 0.12);
  padding: var(--sp-3) var(--sp-5);
  flex-shrink: 0;
}

.footer-inner {
  text-align: center;
  font-family: 'Garet', sans-serif;
  font-size: var(--fs-1);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  font-variant: small-caps;
  color: rgba(200, 191, 176, 0.4);
  opacity: 0.85;
}

.footer-inner .tracked {
  display: inline-block;
  margin-right: -2.5px;
}

.footer-inner .gold-r {
  color: var(--gold);
}

.footer-inner sup {
  font-size: 0.6em;
  vertical-align: super;
  letter-spacing: normal;
}

/* ─── Maintenance Page ───────────────────────────────────────────────────── */

.maintenance-hero {
  justify-content: center;
}

.maintenance-line {
  margin-top: var(--sp-4);
  color: rgba(200, 191, 176, 0.6);
}

/* ─── Maintenance Indicator ──────────────────────────────────────────────── */
/* Shown only to a master session browsing while maintenance is on — the
   rest of the world never reaches this page at all. Corner-anchored so it
   never competes with nav or (on welcome.html) the top-left name label. */

.maint-indicator {
  position: fixed;
  bottom: var(--sp-4);
  right: var(--sp-4);
  z-index: 60;
  font-family: 'Garet', sans-serif;
  font-size: var(--fs-1);
  letter-spacing: 2px;
  margin-right: -2px;
  text-transform: uppercase;
  color: var(--error);
  border: 1px solid rgba(215, 106, 90, 0.4);
  border-radius: var(--radius-sm);
  background: rgba(13, 28, 69, 0.6);
  backdrop-filter: blur(4px);
  padding: 6px 12px;
  pointer-events: none;
}

.maint-indicator[hidden] {
  display: none;
}

/* ─── Welcome Page ───────────────────────────────────────────────────────── */

.welcome-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
}

/* ─── Welcome Page (legacy static labels — superseded by inline animated
       states in welcome.html, kept for no-JS fallback) ────────────────── */

.welcome-greeting {
  font-family: 'Garet', sans-serif;
  font-size: var(--fs-4);
  letter-spacing: 5px;
  margin-right: -5px;
  text-transform: uppercase;
  color: rgba(200, 191, 176, 0.6);
  margin-bottom: var(--sp-3);
}

.welcome-name {
  font-family: 'Garet', sans-serif;
  font-size: clamp(36px, 6vw, 64px);
  letter-spacing: 6px;
  text-transform: uppercase;
  color: var(--gold);
  line-height: 1.1;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  nav {
    padding: var(--sp-3) var(--sp-4) 0;
  }

  /* Ring is now wider than small viewports on purpose: it bleeds off the
     left/right edges (clipped by body's overflow-x: hidden) so its curve
     never has to squeeze the form. Content below is capped to its own
     mobile max-width so it always stays fully on-screen regardless of
     how much of the ring itself is cropped. */
  .ring {
    width: 520px;
    height: 520px;
    gap: var(--sp-4);
  }

  .ring-logo {
    width: 190px;
    height: 55px;
  }

  .tagline,
  .invite-section,
  .session-panel {
    max-width: 300px;
  }

  .invite-form {
    flex-direction: column;
    gap: var(--sp-2);
  }

  .invite-input {
    border-right: 1px solid rgba(215, 154, 63, 0.45);
    border-radius: var(--radius);
  }

  .invite-btn {
    width: 100%;
    border-radius: var(--radius);
  }
}

@media (max-width: 375px) {
  .tagline {
    font-size: var(--fs-1);
  }
}
