/* The Echo Loop — Interactive Edition Stylesheet
   Matches Digital Edition Aesthetics:
   - Light mode: #F6F5F1 cream background, #1C1A18 dark ink
   - Dark mode: #141211 background, #E9E4DA light text
   - Accent: #7A3B3B (the red ribbon / tent / dash)
   - Font: EB Garamond (local, zero external requests)
*/

@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/EBGaramond-Regular.woff') format('woff');
}

@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/EBGaramond-Italic.woff') format('woff');
}

@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/EBGaramond-SemiBold.woff') format('woff');
}

:root {
  --bg: #F6F5F1;
  --bg-secondary: #ECEAE4;
  --ink: #1C1A18;
  --ink-secondary: #5C5852;
  --ink-muted: #8C877E;
  --rule: #DCD8D0;
  --red: #7A3B3B;
  --red-hover: #964747;
  --card: #FFFFFF;
  --font-body: 'EB Garamond', Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141211;
    --bg-secondary: #1C1A18;
    --ink: #E9E4DA;
    --ink-secondary: #B5B0A6;
    --ink-muted: #7E7970;
    --rule: #2C2825;
    --red: #A85252;
    --red-hover: #C26363;
    --card: #1A1816;
  }
}

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

html {
  font-size: 19px;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
}

/* Accessibility Skip Link */
.skip {
  position: absolute;
  top: -100px;
  left: 1rem;
  background: var(--ink);
  color: var(--bg);
  padding: 0.5rem 1rem;
  z-index: 100;
  text-decoration: none;
  font-weight: 600;
}

.skip:focus {
  top: 1rem;
}

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

/* Top Bar & Ribbon Bookmark */
.top-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem;
  height: 2.5rem;
  width: 100%;
}

.save-indicator {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-muted);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.save-indicator.visible {
  opacity: 1;
}

.bookmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.bookmark-btn svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
  transition: transform 0.15s ease;
}

.bookmark-btn:hover svg {
  transform: scale(1.12);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Screen Management — Strict Selector Constraint */
.screen:not(.active) {
  display: none !important;
}

.screen.active {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  align-items: center;
}

/* Splash Screen (One-Viewport Fit, 2:3 Portrait Cover Frame) */
body:has(#splash-screen.active) {
  height: 100vh;
  max-height: 100vh;
  overflow-y: hidden;
}

body:has(#splash-screen.active) .top-bar {
  height: 2rem;
  padding: 0.25rem 1rem;
}

.splash-container {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: 0.25rem 1rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
}

.splash-frame {
  position: relative;
  aspect-ratio: 2 / 3;
  height: clamp(300px, calc(100svh - 11rem), 640px);
  width: auto;
  container-type: inline-size;
  max-width: 90vw;
  margin: 0 auto 0.75rem auto;
  background: var(--card);
  box-shadow: 0 1px 0 var(--rule), 0 8px 30px rgba(0, 0, 0, 0.12);
  border-radius: 2px;
  overflow: hidden;
}

.splash-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0 auto;
}

.splash-title-overlay {
  position: absolute;
  top: 7%;
  left: 0;
  width: 100%;
  text-align: center;
  padding: 0 0.75rem;
}

/* Title is ink on the plate in light and dark modes */
.splash-title {
  font-family: var(--font-body);
  font-size: clamp(1rem, 9cqw, 2rem);
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0;
  color: #1C1A18 !important;
  text-shadow: none !important;
}

.splash-tagline {
  font-style: italic;
  color: #7A3B3B !important;
  font-size: clamp(0.8rem, 4.6cqw, 1rem);
  margin-top: 0.25rem;
  white-space: nowrap;
}

.splash-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  max-width: 18rem;
  width: 100%;
}

body:has(#splash-screen.active) footer {
  padding: 0.5rem 1rem;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--red);
  color: #FFFFFF;
  border: none;
  font-family: var(--font-body);
  font-size: 1.05rem;
  padding: 0.65rem 1.8rem;
  border-radius: 2px;
  cursor: pointer;
  letter-spacing: 0.05em;
  width: 100%;
  text-align: center;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--red-hover);
}

.btn-start-over {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.3rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-start-over:hover {
  color: var(--ink);
}

/* Character Selection Fork Screen ("Whose eyes?") */
.fork-container {
  width: 100%;
  max-width: 58rem;
  padding: 1.5rem 1.25rem 3rem 1.25rem;
  text-align: center;
  margin: 0 auto;
}

.fork-kicker {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
  display: block;
  margin-bottom: 0.3rem;
}

.fork-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 600;
  margin-bottom: 2rem;
  letter-spacing: 0.02em;
}

.characters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  text-align: left;
}

.character-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.character-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--red);
}

.character-portrait {
  width: 100%;
  height: 240px;
  object-fit: cover;
  object-position: center 20%;
  display: block;
  border-bottom: 1px solid var(--rule);
  background-color: var(--bg-secondary);
}

.character-name {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0.9rem 1rem 0.2rem 1rem;
}

.character-meta {
  font-size: 0.85rem;
  color: var(--red);
  font-style: italic;
  margin: 0 1rem 0.6rem 1rem;
}

.character-desc {
  font-size: 0.95rem;
  color: var(--ink-secondary);
  line-height: 1.45;
  margin: 0 1rem 1.25rem 1rem;
  flex: 1;
}

/* Paged Reader Screen */
.reader-container {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem 1.25rem;
}

.act-heading {
  margin-bottom: 1.75rem;
  text-align: center;
}

.act-kicker {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  display: block;
  margin-bottom: 0.25rem;
}

.act-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
}

.plate-container {
  margin: 0 auto 2rem auto;
  width: 100%;
}

.plate-frame {
  position: relative;
  background: var(--card);
  padding: 0.5rem;
  border: 1px solid var(--rule);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  border-radius: 2px;
}

.plate-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1px;
}

.plate-special {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  color: var(--red);
  font-size: 0.85rem;
  font-style: italic;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
}

@media (prefers-color-scheme: dark) {
  .plate-special {
    background: rgba(20, 18, 17, 0.9);
  }
}

.page-text {
  font-size: 1rem;
  line-height: 1.65;
  margin-bottom: 2rem;
}

.page-text p {
  margin-bottom: 1.15rem;
}

.page-text p:last-child {
  margin-bottom: 0;
}

/* Choices Block — Follows prose separated by thin rule */
.choices-block {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}

.choices-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.choice-option {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.45;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  border-radius: 3px;
  position: relative;
  padding-left: 1.4rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.choice-option::before {
  content: '—';
  position: absolute;
  left: 0.2rem;
  color: var(--red);
}

.choice-option:hover {
  background: var(--bg-secondary);
  color: var(--red);
}

/* Nav Controls */
.nav-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.nav-btn {
  background: none;
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.45rem 1.1rem;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--ink);
  color: var(--red);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.nav-indicator {
  font-size: 0.85rem;
  color: var(--ink-muted);
  font-style: italic;
}

/* Dev Stub Screen */
.dev-stub-container {
  width: 100%;
  max-width: 34rem;
  padding: 4rem 1.25rem;
  text-align: center;
  margin: 0 auto;
}

.dev-stub-title {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.dev-stub-text {
  font-size: 1.05rem;
  color: var(--ink-secondary);
  line-height: 1.6;
  margin-bottom: 2rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule);
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
