/* Design tokens */
:root {
  --bg: #000018;        /* infinite-blue */
  --fg: #D0D0C0;        /* platinium */
  --ui: #204070;        /* nebula-blue */
  --accent: #D6D18F;    /* goldinium */
  --danger: #8B0000;    /* deep red */

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;

  --radius-pill: 32px;
  --radius-lg: 32px;

  --font-body: 'Crimson Pro', Georgia, 'Times New Roman', serif;
  --font-brand: 'Tangerine', 'Zapfino', cursive;
}

/* Base */
* { box-sizing: border-box; }
html, body {
  height: 100vh;  /* fallback for older browsers */
  height: 100svh; /* visible viewport on iOS Safari */
  height: 100dvh; /* dynamic visual viewport where supported */
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.5;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

/* Typography */
.brand-title {
  font-family: var(--font-brand);
  color: var(--accent);
}

h1, h2, h3 {
  font-weight: 600;
}

.italic { font-style: italic; }
.center { text-align: center; }

/* Navigation */
.nav-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.nav-link {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--fg);
  text-decoration: none;
  font-size: clamp(1rem, 4vmin, 1.5rem);
}

.section-content {
  height: 100%;
  width: 100%;
  display: grid;
  place-items: center;
}

/* Layout: two sections stacked (mobile-first) */

.page {
  display: grid;
  grid-template-rows: 1fr 1fr;
  grid-template-columns: none;
  height: 100vh;  /* fallback for older browsers */
  height: 100svh; /* visible viewport on iOS Safari */
  height: 100dvh; /* dynamic visual viewport where supported */
  contain: layout style paint;
}

.section-TL {
  display: grid;
  place-items: center;
  grid-column: auto;
  grid-row: auto;
}

.section-BR {
  display: grid;
  place-items: center;
  grid-column: auto;
  grid-row: auto;
}

.section-container {
  width: min(92%, 100%);
  height: 100%;
  display: grid;
  container-type: inline-size;
  position: relative;
}

.hero-image {
  width: 100%;
  height: auto;
  display: block;
}

.hero-brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -1%;
  width: 100%;
  text-align: center;
  pointer-events: none;
  font-size: clamp(1.5rem, 6cqw, 24rem);
}

.hero-brand a {
  text-decoration: none;
  color: inherit;
  pointer-events: auto;
}

/* Player */
.player {
  display: grid;
  gap: var(--space-4);
  justify-items: center;
  background: var(--bg);
  color: var(--ui);
  padding: var(--space-3);
}

.player-title {
  font-style: italic;
  color: var(--fg);  /* platinium color */
}

.player-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: clamp(48px, 12vmin, 60px);
  position: relative;
}

.player-icon {
 width: 1em;
 height: 1em;
 vertical-align: -0.125em;
 color: inherit;
}


/* Side buttons are always present but hidden by default */
#back15, #fwd15 {
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.player-main.middle-state #back15,
.player-main.middle-state #fwd15 {
  visibility: visible;
  opacity: 1;
}

/* Show timer in middle state */
.player-main.middle-state + .timer {
  visibility: visible;
  opacity: 1;
}

.btn {
  background: var(--bg);
  color: var(--ui);
  border: 2px solid var(--ui);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  cursor: pointer;
  min-width: clamp(120px, 45vmin, 180px);
  text-align: center;
  font-family: var(--font-body);
  font-size: clamp(0.8rem, 3vmin, 1rem);
}

.btn.round {
  width: clamp(36px, 11vmin, 44px);
  height: clamp(36px, 11vmin, 44px);
  display: grid;
  place-items: center;
  padding: 0;           /* Override main button padding */
  border-radius: 50%;   /* Perfect circle */
  min-width: auto;      /* Override main button min-width */
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.timer {
  color: var(--ui);
  font-family: var(--font-body);
  font-style: italic;
  font-size: clamp(0.8rem, 3vmin, 1rem);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  min-height: 1.2em;  /* Maintain space even when hidden */
}

.error {
  color: var(--danger);
  border-color: var(--danger);
}

.next-links {
  text-align: center;
  color: var(--ui);
  font-family: var(--font-body);
  font-style: italic;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease;
  min-height: 3.6em;  /* Reserve space for 3 lines of text */
  display: flex;
  align-items: center;
  justify-content: center;
}

.next-links a {
  text-decoration: none;
  color: var(--ui);
}

/* Show next-links in end state */
.player-main.end-state + .timer + .next-links {
  visibility: visible;
  opacity: 1;
}

/* Landscape: side-by-side */
/* Portrait: ensure proper reset */
@media (orientation: portrait) {
  .page {
    grid-template-rows: 1fr 1fr !important;
    grid-template-columns: none !important;
  }
  .section-TL {
    grid-column: auto !important;
    grid-row: auto !important;
  }
  .section-BR {
    grid-column: auto !important;
    grid-row: auto !important;
  }
}

/* Landscape: side-by-side layout */
@media (orientation: landscape) {
  .page {
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: none !important;
  }
  .section-TL {
    grid-column: 1 !important;
    grid-row: 1 !important;
  }
  .section-BR {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }
}

.form-hero {
  display: grid;
  gap: var(--space-2);
  text-align: center;
  padding: clamp(1.5rem, 3vmin, 3rem);
  color: var(--fg);
}

.form-hero p {
  max-width: 38ch;
  margin-inline: auto;
}

.form-card {
  background: rgba(20, 28, 48, 0.65);
  border: 1px solid rgba(214, 209, 143, 0.2);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 3vmin, 3rem);
  width: min(520px, 100%);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.form-card header {
  margin-bottom: var(--space-3);
}

.form-card h2 {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: clamp(1.5rem, 3vmin, 2rem);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: var(--space-2);
  font-size: clamp(0.9rem, 2vmin, 1rem);
}

.form-field label {
  font-weight: 600;
  color: var(--ui);
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  background: rgba(12, 16, 32, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--fg);
  font: inherit;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(214, 209, 143, 0.4);
}

.form-field textarea {
  resize: vertical;
  min-height: 100px;
}

.checkbox-field {
  flex-direction: row;
  align-items: center;
}

.checkbox-field input {
  width: auto;
  margin-right: 0.5rem;
}

.form-card .btn {
  width: 100%;
  border-color: var(--accent);
  color: var(--fg);
  background: linear-gradient(135deg, rgba(214, 209, 143, 0.2), rgba(214, 209, 143, 0.05));
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.form-card .btn:hover,
.form-card .btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
}

.form-message {
  min-height: 1.8em;
  margin-top: var(--space-2);
}

.form-message.success {
  color: var(--accent);
}

.form-message.error {
  color: var(--danger);
}
