/*
  Perceptron Quotes - styles
  ---------------------------
  Visual design notes:
  · Dark, cinematic atmosphere with subtle gradients and glows
  · Organic canvas lines layered behind the content
  · Control panel feels like an instrument cluster
  · Typography blends serif poetry with clean sans-serif utility
*/

:root {
  color-scheme: dark;
  --bg: #050505;
  --text-primary: #f4ede0;
  --text-muted: rgba(244, 237, 224, 0.7);
  --accent: #f85f73;
  --accent-alt: #53c6f8;
  --panel: rgba(17, 17, 17, 0.76);
  --panel-border: rgba(244, 237, 224, 0.08);
  --shadow: 0 32px 60px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: radial-gradient(circle at 20% 20%, rgba(248, 95, 115, 0.08), transparent 55%),
    radial-gradient(circle at 80% 15%, rgba(83, 198, 248, 0.08), transparent 50%),
    var(--bg);
  min-height: 100%;
  color: var(--text-primary);
  font-family: "Cormorant Garamond", "Iowan Old Style", "Palatino", serif;
}

body {
  display: flex;
}

canvas#glyphCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  padding: clamp(2rem, 5vw, 4rem);
}

.hero {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: clamp(2.5rem, 4vw, 3.5rem);
  text-transform: uppercase;
  letter-spacing: 0.28em;
}

.hero__label {
  font-size: clamp(1rem, 2vw, 1.3rem);
}

.hero__sub {
  font-size: clamp(0.75rem, 1.1vw, 0.95rem);
  color: var(--text-muted);
  letter-spacing: 0.18em;
}

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: stretch;
}

.stage__poem {
  background: linear-gradient(145deg, rgba(248, 95, 115, 0.07), rgba(83, 198, 248, 0.07));
  border-radius: 36px;
  padding: clamp(2rem, 5vw, 3.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.2rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.poem__stanza {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  font-size: clamp(1.4rem, 2.8vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: 0.015em;
  color: var(--text-primary);
  overflow-wrap: break-word;
  word-break: normal;
}

.poem__stanza::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(248, 95, 115, 0.06), transparent 65%);
  pointer-events: none;
}

.poem__line {
  margin: 0;
  opacity: 0;
  transform: translateY(12px);
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
}

.poem__line.reveal {
  animation: inkReveal 0.85s ease forwards;
}

@keyframes inkReveal {
  0% {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.poem__citation {
  font-size: clamp(0.8rem, 1.1vw, 0.95rem);
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.poem__citation span {
  background: rgba(244, 237, 224, 0.08);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(244, 237, 224, 0.12);
  letter-spacing: 0.08em;
}

/* Loading indicator styles */
.loading-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 2rem;
  margin: 0.5rem 0;
}

.loading-indicator.hidden {
  display: none;
}

.loading-dots {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.loading-dots .dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: loadingPulse 1.4s ease-in-out infinite both;
}

.loading-dots .dot:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots .dot:nth-child(2) {
  animation-delay: -0.16s;
}

.loading-dots .dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes loadingPulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

.stage__controls {
  backdrop-filter: blur(22px);
  background: var(--panel);
  border-radius: 28px;
  padding: clamp(1.9rem, 4vw, 2.6rem);
  border: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  box-shadow: var(--shadow);
  position: relative;
  max-height: fit-content;
}

.stage__controls::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 26px;
  border: 1px solid rgba(244, 237, 224, 0.06);
  pointer-events: none;
}

.stage__controls h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.controls__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.controls__group {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.toggle {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(244, 237, 224, 0.05);
  padding: 1rem 1.1rem;
  border-radius: 20px;
  border: 1px solid rgba(244, 237, 224, 0.08);
  position: relative;
  overflow: hidden;
}

.toggle::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(248, 95, 115, 0.12), rgba(83, 198, 248, 0.1));
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.toggle:hover::before {
  opacity: 1;
}

.toggle__label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.toggle__label span:last-child {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
}

.toggle input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  appearance: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
  outline: none;
}

.toggle input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
}

.toggle input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid #050505;
  margin-top: -6px;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
}

.toggle input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
}

.toggle input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid #050505;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.4);
}

.controls__regen {
  align-self: flex-start;
  background: linear-gradient(120deg, rgba(248, 95, 115, 0.26), rgba(83, 198, 248, 0.22));
  color: var(--text-primary);
  border: 1px solid rgba(244, 237, 224, 0.18);
  border-radius: 999px;
  padding: 0.85rem 1.9rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.controls__regen:disabled {
  opacity: 0.4;
  cursor: progress;
}

.controls__regen:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(248, 95, 115, 0.3);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 5, 0.75);
  display: grid;
  place-items: center;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay__content {
  background: rgba(8, 8, 8, 0.85);
  border: 1px solid rgba(244, 237, 224, 0.1);
  border-radius: 24px;
  padding: clamp(2rem, 5vw, 3rem);
  max-width: min(620px, 90vw);
  text-align: center;
  box-shadow: var(--shadow);
}

.overlay__label {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.overlay blockquote {
  margin: 1.5rem 0 1rem;
  font-size: clamp(1.2rem, 3vw, 2rem);
  line-height: 1.25;
}

.overlay cite {
  font-style: normal;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.overlay__continue {
  margin-top: 1.75rem;
  border: none;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  background: rgba(244, 237, 224, 0.15);
  color: var(--text-primary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease;
}

.overlay__continue:hover {
  background: rgba(244, 237, 224, 0.3);
}

@media (max-width: 1040px) {
  .stage {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .stage__controls {
    max-width: min(540px, 92vw);
  }
}

@media (max-width: 600px) {
  :root {
    font-size: 15px;
  }

  .app-shell {
    padding: 1.75rem;
  }

  .stage__poem {
    border-radius: 24px;
    padding: 1.75rem;
  }

  .stage__controls {
    border-radius: 20px;
    padding: 1.5rem;
  }

  .toggle {
    padding: 0.85rem 0.95rem;
  }
}