/* =========================================================
   MON ROSIER — stylesheet
   Palette:
     --ink        #150308  near-black wine, page background
     --wine       #3a071f  rose ink, panel background
     --wine-soft  #4d0f2a  lighter panel / hover
     --blush-wine #6f1f3b  borders, accents
     --petal      #b65a7c  active accent, links
     --powder     #e2a6ba  muted text
     --ivory      #fdf3f0  primary text
   ========================================================= */
   
@import url('https://fonts.googleapis.com/css2?family=Tangerine:wght@400;700&family=Zen+Antique+Soft&display=swap');
@import url('https://fonts.googleapis.com/css2?family=MonteCarlo&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Marck+Script&display=swap');

:root {
  --ink: #150308;
  --ink-deep: #0d0205;
  --wine: #33071c;
  --wine-soft: #451028;
  --blush-wine: #6f1f3b;
  --petal: #c46e8f;
  --petal-bright: #e2a6ba;
  --powder: #cf95a9;
  --ivory: #fbeeec;
  --ivory-dim: #e7d3d2;
  --font-brand: 'Tangerine'; /* just for .brand, sparingly */
  --font-display: 'MonteCarlo';
  --font-body: 'Spectral', serif;
  --font-links: 'Marck Script';
  --radius: 1px;
  --border: 1px solid rgba(226, 166, 186, 0.22);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ink);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(111, 31, 59, 0.35), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(58, 7, 28, 0.5), transparent);
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection {
  background: var(--blush-wine);
  color: var(--ivory);
}

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

/* Focus visibility */
a:focus-visible,
button:focus-visible {
  outline: 1px solid var(--petal-bright);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------
   Ambient falling petals (decorative, behind content)
--------------------------------------------------------- */
.petal-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.petal {
  position: absolute;
  top: -5vh;
  width: 10px;
  height: 10px;
  background: var(--petal);
  opacity: 0.35;
  border-radius: 0 60% 0 60%;
  animation: fall linear infinite;
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(220deg);
  }
}

/* ---------------------------------------------------------
   Page shell
--------------------------------------------------------- */
.page {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 40px 50px;
}

/* ---------------------------------------------------------
   Banner / hero — flip card
--------------------------------------------------------- */
.banner {
  perspective: 2200px;
  margin-bottom: 40px;
}

.banner-flip {
  position: relative;
  min-height: 380px;
  border: var(--border);
  background: linear-gradient(160deg, var(--wine) 0%, var(--ink-deep) 120%);
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.7);
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(.4,.2,.2,1);
}

.banner-flip.is-flipped {
  transform: rotateY(180deg);
}

.banner-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px 64px;
}

.banner-front {
  background-image:
    linear-gradient(180deg, rgba(13,2,5,0.15) 0%, rgba(13,2,5,0.75) 75%, rgba(13,2,5,0.92) 100%),
    url('images/banner-image.jpeg');
  background-size: cover;
  background-position: center;
}

.banner-front::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 30%, rgba(196, 110, 143, 0.12), transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(111, 31, 59, 0.35), transparent 55%);
  pointer-events: none;
}

.banner-back {
  transform: rotateY(180deg);
  justify-content: center;
  margin: 0 auto;
  align-items: flex-start;
}

.brand {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: clamp(48px, 7vw, 84px);
  letter-spacing: 0.03em;
  color: var(--ivory);
  text-shadow: 0 2px 40px rgba(196, 110, 143, 0.25);
}

.tagline {
  margin: -20px 0 30px;
  max-width: 46ch;
  font-style: italic;
  font-size: 22px;
  color: var(--ivory-dim);
  font-weight: 400;
}

.about-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  gap: 10px;
  align-self: flex-start;
  padding: 8px 16px;
  border: 1px solid rgba(226, 166, 186, 0.4);
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.18em;
  color: var(--petal-bright);
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.about-toggle:hover {
  background: var(--petal-bright);
  color: var(--ink-deep);
  border-color: var(--petal-bright);
}

.about-toggle-arrow {
  transition: transform 0.3s ease;
}
.about-toggle-arrow.flipped { transform: rotate(180deg); }

.about-heading {
  margin: 0 auto 5px;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--ivory);
  font-weight: 600;
}

.about-text {
  max-width: 56ch;
  font-size: 19px;
  color: var(--ivory-dim);
  margin: 0 auto 15px;
  text-align: center;
}

/* ---------------------------------------------------------
   Grid section
--------------------------------------------------------- */
.grid-section {
  display: grid;
  grid-template-columns: 1.3fr 1.12fr 0.85fr 1.08fr;
  gap: 24px;
  align-items: stretch;
}

.panel {
  background: linear-gradient(175deg, var(--wine) 0%, var(--ink-deep) 140%);
  border: var(--border);
  padding: 20px;
  overflow-y: scroll;
}

.panel-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--ivory);
  letter-spacing: 0.01em;
}

.panel-title--display {
  margin-bottom: 10px;
}

/* --- Column 1: detail panel --- */
.panel-detail {
  display: flex;
  flex-direction: column;
  height: 450px;
  padding: 0;
  overflow: hidden;
  overflow-y: scroll;
}

/* Default state: full-bleed image, no padding/title showing */
.panel-detail-image {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  line-height: 0;
  display: block;
}

.panel-detail-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.85) contrast(1.02);
  transition: filter 0.4s ease, transform 0.6s ease;
}

.panel-detail-image:hover img {
  filter: saturate(1.05) contrast(1.05);
  transform: scale(1.03);
}

/* Active state: text content, shown only when a nav card is selected */

.panel-detail.has-active .panel-detail-image {
  display: none;
}

.panel-detail.has-active .panel-detail-content {
  display: flex;
}

.panel-detail-content {
  display: none;
  flex-direction: column;
  min-height: 100%;   /* was: height: 100%; — let it grow, don't force-fit */
  padding: 20px;
}

.panel-divider {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--petal-bright), transparent);
  margin-top: 4px;
  margin-bottom: 20px;
  opacity: 0.8;
  flex-shrink: 0;   /* never let this collapse, regardless of content length */
}

.panel-body p {
  color: var(--ivory-dim);
  font-size: 16px;
  margin: 0 0 17px;
}

.panel-list {
  margin: 0;
  padding-left: 20px;
  color: var(--powder);
  font-size: 16px;
}

.panel-list li { margin-bottom: 8px; }

.panel-detail.is-updating .panel-body {
  animation: detail-fade 0.4s ease;
}

@keyframes detail-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Column 2: links --- */
.panel-links {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.link-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 15px;
  border: 1px solid rgba(226, 166, 186, 0.18);
  font-family: var(--font-links);
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--ivory-dim);
  background: rgba(0,0,0,0.12);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.link-row:hover {
  border-color: var(--petal);
  color: var(--ivory);
  background: rgba(111, 31, 59, 0.35);
  transform: translateX(4px);
}

.link-row--minor {
  color: var(--powder);
  opacity: 0.7;
  font-size: 13px;
  padding: 10px 18px;
}

.link-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--petal-bright);
  flex-shrink: 0;
}

/* --- Column 3: stacked images ---
   600px is the ONE number that controls the height of the whole row.
   Change it here and everything else (links, nav cards, detail panel)
   stretches to match automatically. */
.panel-imagestack {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 450px;
}

.panel-image {
  margin: 0;
  padding: 0;
  overflow: hidden;
  line-height: 0;
  flex: 1;
  min-height: 0;
}

.panel-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.85) contrast(1.02);
  transition: filter 0.4s ease, transform 0.6s ease;
}

.panel-image:hover img {
  filter: saturate(1.05) contrast(1.05);
  transform: scale(1.03);
}

/* --- Column 4: nav cards --- */
.nav-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.nav-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  padding: 15px 20px;
  border: var(--border);
  background: linear-gradient(175deg, var(--wine) 0%, var(--ink-deep) 140%);
  flex: 1;
  transition: background 0.3s ease, border-color 0.3s ease,
              filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.nav-card h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ivory);
}

.nav-card p {
  margin: 0;
  font-size: 16px;
  color: var(--powder);
}

.nav-card:hover,
.nav-card:focus-visible {
  border-color: var(--petal);
  transform: translateX(-2px);
}

/* Group-hover blur/dim effect, mirrors the sketch's annotation.
   Non-active cards are also click-disabled while one is active. */
.nav-cards.has-active .nav-card {
  filter: blur(1.5px) brightness(0.6);
  opacity: 0.65;
  pointer-events: none;
}

.nav-cards.has-active .nav-card.is-active {
  filter: none;
  opacity: 1;
  background: linear-gradient(175deg, var(--blush-wine) 0%, var(--wine) 140%);
  border-color: var(--petal-bright);
  transform: translateX(-2px) scale(1.01);
  pointer-events: auto;
}

.nav-card--fade {
  overflow: hidden;
}

.nav-card-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--ink-deep));
  pointer-events: none;
}

/* ---------------------------------------------------------
   Responsive
--------------------------------------------------------- */
@media (max-width: 1100px) {
  .grid-section {
    grid-template-columns: 1fr 1fr;
  }
  .panel-imagestack {
    grid-column: span 2;
    flex-direction: row;
    height: 300px;
  }
}

@media (max-width: 700px) {
  .page { padding: 28px 18px 70px; }
  .banner-face { padding: 36px 28px; }
  .brand { font-size: 44px; }
  .tagline { font-size: 18px; }
  .grid-section { grid-template-columns: 1fr; }
  .panel-imagestack {
    grid-column: span 1;
    flex-direction: column;
    height: 480px;
  }
  .banner-flip { min-height: 420px; }
}

/* ---------------------------------------------------------
   Mobile fix: nav cards + detail panel visibility
--------------------------------------------------------- */
@media (max-width: 700px) {

  .grid-section {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Reorder so nav cards come first, then the detail panel opens
     right underneath them — not buried above, out of view. */
  .nav-cards {
    order: 1;
    height: auto;
  }

  .nav-card {
    flex: none;
    padding: 14px 18px;
  }

  .panel-detail {
    order: 2;
    height: auto;
    max-height: none;
  }

  .panel-detail-image {
    height: 240px;
    flex: none;
  }

  .panel-links {
    order: 3;
  }

  .panel-imagestack {
    order: 4;
    grid-column: auto;
    flex-direction: column;
    height: auto;
  }

  .panel-image {
    height: 220px;
    flex: none;
  }

  /* Give the open detail panel a clear visual anchor so it reads
     as "this just opened" even without scrolling context */
  .panel-detail.has-active {
    border-color: var(--petal-bright);
    box-shadow: 0 0 0 1px rgba(226, 166, 186, 0.25);
  }

  .panel-detail-content {
    padding: 18px;
    max-height: 60vh;
    overflow-y: auto;
  }

  .panel-title {
    font-size: 22px;
  }

  .link-row {
    font-size: 16px;
    padding: 12px 14px;
  }
}


/* =========================================================
   SUB-PAGES (writing.html, worlds.html)
   Shared back-link + sub-banner + writing page components
   ========================================================= */

/* --- Back link --- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.1em;
  color: var(--powder);
  transition: color 0.2s ease, transform 0.2s ease;
}

.back-link:hover {
  color: var(--petal-bright);
  transform: translateX(-3px);
}

.back-link svg {
  flex-shrink: 0;
}

.subbanner {
  background-image:
    linear-gradient(180deg, rgba(13,2,5,0.15) 0%, rgba(13,2,5,0.75) 75%, rgba(13,2,5,0.92) 100%),
    url('images/writing-banner.jpeg');
  background-size: cover;
  background-position: center;
  box-shadow:
    inset 0 0 0 1px rgba(226, 166, 186, 0.22),
    0 30px 60px -30px rgba(0,0,0,0.7);
  padding: 48px 56px;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}


.subbanner::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 30%, rgba(196, 110, 143, 0.12), transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(111, 31, 59, 0.35), transparent 55%);
  pointer-events: none;
}

.subbanner-title {
  position: relative;
  margin: 0 0 10px;
  font-family: var(--font-brand);
  font-weight: 600;
  font-size: clamp(40px, 6vw, 64px);
  color: var(--ivory);
  text-shadow: 0 2px 40px rgba(196, 110, 143, 0.25);
}

.subbanner-tagline {
  position: relative;
  margin: 0;
  max-width: 50ch;
  font-style: italic;
  font-size: 19px;
  color: var(--ivory-dim);
}

/* ---------------------------------------------------------
   Writing page grid
--------------------------------------------------------- */
.writing-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 24px;
  align-items: start;
}

.panel-writing-about {
  height: 520px;
  overflow-y: scroll;
  position: sticky;
  top: 24px;
}

.panel-writing-about .panel-body p {
  color: var(--ivory-dim);
  font-size: 16px;
  margin: 0 0 14px;
}

.panel-writing-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Search + filter controls row --- */
.story-controls {
  display: flex;
  gap: 14px;
  align-items: stretch;
}

.story-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: var(--border);
  background: linear-gradient(175deg, var(--wine) 0%, var(--ink-deep) 140%);
  transition: border-color 0.2s ease;
}

.story-search:focus-within {
  border-color: var(--petal);
}

.story-search-icon {
  flex-shrink: 0;
  color: var(--powder);
}

.story-search input {
  flex: 1;
  border: none;
  background: none;
  color: var(--ivory);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 14px 0;
  outline: none;
}

.story-search input::placeholder {
  color: var(--powder);
  opacity: 0.75;
}

/* --- Tag filter dropdown --- */
.story-filter {
  position: relative;
  flex-shrink: 0;
}

.filter-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 0 20px;
  border: var(--border);
  background: linear-gradient(175deg, var(--wine) 0%, var(--ink-deep) 140%);
  font-family: var(--font-links);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--petal-bright);
  white-space: nowrap;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.filter-toggle:hover {
  border-color: var(--petal);
}

.filter-toggle-arrow {
  transition: transform 0.25s ease;
}

.story-filter.is-open .filter-toggle-arrow {
  transform: rotate(180deg);
}

.filter-dropdown {
  display: none;
  flex-direction: column;
  gap: 4px;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  min-width: 220px;
  max-height: 280px;
  overflow-y: auto;
  padding: 10px;
  border: var(--border);
  background: linear-gradient(175deg, var(--wine-soft) 0%, var(--ink-deep) 140%);
  box-shadow: 0 20px 40px -20px rgba(0,0,0,0.8);
}

.story-filter.is-open .filter-dropdown {
  display: flex;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-family: var(--font-links);
  font-size: 17px;
  color: var(--ivory-dim);
  transition: background 0.15s ease, color 0.15s ease;
}

.filter-option:hover {
  background: rgba(111, 31, 59, 0.35);
  color: var(--ivory);
}

.filter-option input {
  accent-color: var(--petal);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.filter-option.is-checked {
  color: var(--petal-bright);
}

/* --- Chosen / active tag chips row (scrollable) --- */
.chosen-tags {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chosen-tags:empty {
  display: none;
}

.chosen-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 6px 10px 6px 14px;
  border: 1px solid rgba(226, 166, 186, 0.4);
  background: rgba(111, 31, 59, 0.35);
  font-family: var(--font-links);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--petal-bright);
  white-space: nowrap;
}

.chosen-tag button {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--powder);
  font-size: 14px;
  line-height: 1;
  transition: color 0.15s ease;
}

.chosen-tag button:hover {
  color: var(--ivory);
}

/* --- Story cards --- */
.story-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.story-card {
  border: var(--border);
  background: linear-gradient(175deg, var(--wine) 0%, var(--ink-deep) 140%);
  padding: 24px 28px;
  transition: border-color 0.2s ease;
}

.story-card:hover {
  border-color: var(--blush-wine);
}

.story-card-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--ivory);
  border-bottom: 1px solid rgba(226, 166, 186, 0.25);
  padding-bottom: 8px;
}

.story-card-desc {
  margin: 14px 0 16px;
  font-size: 16px;
  color: var(--ivory-dim);
}

.story-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.story-tag {
  padding: 5px 8px;
  border: 1px solid rgba(226, 166, 186, 0.3);
  font-family: var(--font-body);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--powder);
}

.story-card-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid rgba(226, 166, 186, 0.4);
  font-family: var(--font-links);
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--petal-bright);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.story-card-link:hover {
  background: var(--petal-bright);
  color: var(--ink-deep);
  border-color: var(--petal-bright);
}

.story-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--powder);
  font-style: italic;
}

/* ---------------------------------------------------------
   Responsive
--------------------------------------------------------- */
@media (max-width: 1000px) {
  .writing-grid {
    grid-template-columns: 1fr;
  }
  .panel-writing-about {
    height: auto;
    max-height: 260px;
    position: static;
  }
}

@media (max-width: 700px) {
  .subbanner { padding: 32px 24px; }
  .story-controls { flex-direction: column; }
  .filter-dropdown { left: 0; right: 0; min-width: 0; }
  .story-card { padding: 20px; }
}


/* =========================================================
   WORLDS PAGE (worlds.html)
   Reuses .subbanner / .writing-grid / .story-* system from
   the writing page. Adds: per-world banner image on cards,
   and a two-button link row (The Lore / The Bots).
   ========================================================= */

.subbanner--worlds {
  background-image:
    linear-gradient(180deg, rgba(13,2,5,0.15) 0%, rgba(13,2,5,0.75) 75%, rgba(13,2,5,0.92) 100%),
    url('images/worlds-banner.jpeg');
}

/* --- World card banner image --- */
.world-card-image {
  margin: -24px -28px 18px;
  line-height: 0;
  overflow: hidden;
  height: 180px;
}

.world-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(0.85) contrast(1.02);
  transition: filter 0.4s ease, transform 0.6s ease;
}

.story-card:hover .world-card-image img {
  filter: saturate(1.05) contrast(1.05);
  transform: scale(1.03);
}

/* --- Two-button link row (The Lore / The Bots) --- */
.story-card-links {
  display: flex;
  gap: 10px;
}

.story-card-links .story-card-link {
  flex: 1;
  justify-content: center;
}

@media (max-width: 700px) {
  .world-card-image {
    margin: -20px -20px 16px;
    height: 150px;
  }
  .story-card-links {
    flex-direction: column;
  }
}