@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=Outfit:wght@300;400;500&display=swap");

:root,
body.theme-night {
  --ui-ink: rgba(255, 255, 255, 0.92);
  --ui-muted: rgba(255, 255, 255, 0.55);
  --ui-glass: rgba(8, 10, 14, 0.42);
  --ui-line: rgba(255, 255, 255, 0.16);
  --ui-soft: rgba(255, 255, 255, 0.08);
  --ui-shadow: 0 1px 18px rgba(0, 0, 0, 0.55);
  --ui-font: "Outfit", system-ui, sans-serif;
  --ui-display: "Cormorant Garamond", Georgia, serif;
}

body.theme-light {
  --ui-ink: rgba(18, 18, 22, 0.9);
  --ui-muted: rgba(18, 18, 22, 0.52);
  --ui-glass: rgba(255, 255, 255, 0.52);
  --ui-line: rgba(18, 18, 22, 0.14);
  --ui-soft: rgba(18, 18, 22, 0.06);
  --ui-shadow: 0 1px 18px rgba(255, 255, 255, 0.35);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050608;
  font-family: var(--ui-font);
  color: var(--ui-ink);
}

main {
  width: 100%;
  height: 100%;
  margin: 0;
}

/* —— Mobile / tablet desktop-only gate (non-dismissible) —— */
html.is-mobile-blocked,
body.is-mobile-blocked {
  overflow: hidden !important;
}

body.is-mobile-blocked > *:not(#desktop-only-gate) {
  visibility: hidden !important;
  pointer-events: none !important;
}

.desktop-only-gate {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  box-sizing: border-box;
  background:
    radial-gradient(ellipse 80% 60% at 50% 45%, #2a3148 0%, #0c1018 55%, #050608 100%),
    #050608;
  visibility: visible !important;
  pointer-events: auto !important;
}

.desktop-only-gate-panel {
  width: min(420px, 100%);
  padding: 8px 4px;
  text-align: center;
}

.desktop-only-gate-text {
  margin: 0;
  font-family: var(--ui-display, "Cormorant Garamond", Georgia, serif);
  font-size: clamp(22px, 5.5vw, 30px);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.92);
}

canvas {
  display: block;
  vertical-align: top;
}

/* Hide sketch chrome until View Gallery */
body:not(.has-started) .left-chrome,
body:not(.has-started) .right-stack,
body:not(.has-started) .nav-btn {
  opacity: 0;
  pointer-events: none;
}

/* —— Start screen —— */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  box-sizing: border-box;
  /* Opaque night wash (no alpha) so the canvas underneath never bleeds through */
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, #2a3148 0%, #0c1018 55%, #050608 100%),
    linear-gradient(180deg, #07090e 0%, #050608 100%);
  transition: opacity 400ms ease, visibility 400ms ease;
}

.start-screen.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.start-screen[hidden] {
  display: none !important;
}

.start-panel {
  width: min(640px, 100%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.start-title {
  margin: 0 0 18px;
  font-family: var(--ui-display);
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.05;
  color: rgba(255, 255, 255, 0.94);
}

.start-desc {
  margin: 0 0 14px;
  font-family: var(--ui-font);
  font-size: 15px;
  font-weight: 300;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.62);
}

.start-desc + .start-disclaimer {
  margin-top: 8px;
}

.start-disclaimer {
  margin: 0 0 28px;
  padding: 12px 14px;
  border-left: 2px solid rgba(255, 255, 255, 0.22);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.48);
}

.start-disclaimer p {
  margin: 0;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.start-begin-btn {
  height: 44px;
  margin: 0;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.94);
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.start-begin-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.94);
}

.start-begin-btn:active {
  transform: scale(0.98);
}

@media (max-width: 520px) {
  .start-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .start-begin-btn {
    width: 100%;
  }
}

/* —— Left chrome (story + Mode panel) —— */
.left-chrome {
  position: fixed;
  top: 28px;
  left: 32px;
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  max-width: min(420px, calc(100vw - 160px));
}

.site-nav-link {
  color: var(--ui-muted);
  text-decoration: none;
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: auto;
  transition: color 160ms ease;
}

.site-nav-link:hover {
  color: var(--ui-ink);
}

.generate-story-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px; /* shared with audio + playbar */
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  background: var(--ui-glass);
  color: var(--ui-ink);
  font-family: var(--ui-font);
  font-size: 12px; /* slightly larger — primary CTA */
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-sizing: border-box;
  transition: background 160ms ease, border-color 160ms ease;
}

.generate-story-btn:hover {
  background: var(--ui-soft);
  border-color: var(--ui-ink);
}

.story-card {
  position: relative;
  pointer-events: none;
  text-shadow: var(--ui-shadow);
}

.story-names {
  font-family: var(--ui-display);
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.1;
  margin: 0;
}

.story-duration {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 300;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ui-muted);
}

/* —— Side story navigation —— */
.nav-btn {
  position: fixed;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  background: var(--ui-glass);
  color: var(--ui-ink);
  line-height: 0;
  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(10px);
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.nav-btn .nav-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav-btn:hover {
  background: rgba(12, 14, 18, 0.72);
  border-color: rgba(255, 255, 255, 0.32);
}

.nav-btn:active {
  transform: scale(0.96);
}

/* —— Right column (stacked chrome + transport) —— */
.right-stack {
  position: fixed;
  top: 28px;
  right: 32px;
  bottom: 28px;
  z-index: 14;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  width: max-content;
  max-width: calc(100vw - 64px);
  pointer-events: none;
}

.right-stack > * {
  pointer-events: auto;
}

.right-chrome {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.right-chrome .generate-story-btn {
  justify-content: center;
  box-sizing: border-box;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px; /* shared with Tell me + playbar */
  padding: 0 14px; /* match playbar */
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  background: var(--ui-glass);
  backdrop-filter: blur(10px);
  box-sizing: border-box;
}

.audio-controls.is-muted .volume-slider {
  opacity: 0.35;
}

.mode-menu-btn {
  position: relative;
  height: 36px;
  margin: 0;
  padding: 0 16px;
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  background: var(--ui-glass);
  color: var(--ui-ink);
  font-family: var(--ui-font);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 160ms ease, border-color 160ms ease;
}

.generate-story-btn:hover,
.mode-menu-btn:hover,
.mode-menu.is-open .mode-menu-btn {
  background: var(--ui-soft);
  border-color: var(--ui-ink);
}

.volume-slider {
  flex: 1 1 auto;
  width: auto;
  min-width: 48px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--ui-ink);
}

.mode-menu {
  position: relative;
  pointer-events: auto;
}

.mode-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: auto;
  width: min(300px, calc(100vw - 48px));
  padding: 14px;
  border: 1px solid var(--ui-line);
  border-radius: 18px;
  background: var(--ui-glass);
  backdrop-filter: blur(16px);
  box-shadow: var(--ui-shadow);
  box-sizing: border-box;
}

.mode-menu-panel[hidden] {
  display: none !important;
}

.mode-menu-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ui-muted);
}

.mode-menu-status {
  margin-top: 6px;
  margin-bottom: 12px;
  font-family: var(--ui-font);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1.45;
  color: var(--ui-muted);
}

.mode-option {
  padding: 10px 0;
  border-top: 1px solid var(--ui-line);
}

.mode-option-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.mode-option-label input[type="radio"] {
  margin-top: 4px;
  accent-color: var(--ui-ink);
  cursor: pointer;
}

.mode-option-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.mode-option-name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ui-ink);
}

.mode-option-hint {
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--ui-muted);
}

.mode-time-row,
.mode-chip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  margin-left: 22px;
}

.mode-time-row.is-disabled,
.mode-chip-row.is-disabled {
  opacity: 0.42;
  pointer-events: none;
}

.mode-time-slider {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  cursor: pointer;
  accent-color: var(--ui-ink);
}

.mode-time-label {
  flex: 0 0 auto;
  min-width: 68px;
  font-size: 11px;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--ui-muted);
  text-align: right;
}

.mode-chip-row {
  flex-wrap: wrap;
}

.mode-chip {
  height: 28px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  background: transparent;
  color: var(--ui-ink);
  font-family: var(--ui-font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}

.mode-chip:hover {
  background: var(--ui-soft);
}

.mode-chip.is-active {
  background: var(--ui-soft);
  border-color: var(--ui-ink);
}

/* —— Transport bar (bottom of right stack; width matches chrome) —— */
.transport-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: stretch;
  width: auto;
  min-width: 0;
  height: 44px; /* shared with Tell me / audio */
  padding: 0 14px;
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  background: var(--ui-glass);
  backdrop-filter: blur(14px);
  box-sizing: border-box;
}

.transport-bar .timeline-slider {
  margin-left: 4px;
  margin-right: 4px;
}

/* Shared icon chip: play / pause / replay / mute */
.transport-icon-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--ui-soft);
  color: var(--ui-ink);
  line-height: 0;
  cursor: pointer;
  transition: background 160ms ease;
}

.transport-icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.transport-icon-btn .transport-icon {
  display: block;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.timeline-slider {
  flex: 1 1 auto;
  margin: 0;
  min-width: 0;
  height: 14px;
  cursor: pointer;
  accent-color: rgba(255, 255, 255, 0.85);
}

.time-readout {
  flex: 0 0 auto;
  min-width: 0;
  padding: 0;
  color: var(--ui-muted);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-align: left;
  pointer-events: none;
  white-space: nowrap;
}
