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

/* Lovely May (VP Creative Shop) — the subtly arboreal serif of the nav word-art,
   self-hosted so the live sigil renders in the same hand as Branch/Hyphae/Rooth. */
@font-face {
  font-family: 'Lovely May';
  src: url('assets/fonts/LovelyMay-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

:root {
  --dark-glass: rgba(20, 18, 15, 0.72);
  --dark-glass-hover: rgba(20, 18, 15, 0.88);
  --border-glass: rgba(200, 190, 170, 0.13);
  --text-primary: rgba(230, 222, 208, 0.84);
  --text-secondary: rgba(180, 170, 155, 0.75);
  --panel-width: min(520px, 55vw);
  --overlap: 20px;
}

html, body { height: 100%; width: 100%; }
body {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 300; color: var(--text-primary); background: #0a0906; overflow-x: hidden;
}
body.branch { display: flex; flex-direction: column; min-height: 100vh; }

.bg { position: fixed; inset: 0; background-size: cover; background-position: center 30%; z-index: 0; }
.bg::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(3,2,2,.85);
}

.layout {
  position: relative; z-index: 1; min-height: 100vh; padding: 3vh 3vw;
  display: grid; grid-template-columns: var(--panel-width) 1fr; grid-template-rows: auto 1fr; align-items: start;
}
.layout.split { grid-template-columns: var(--panel-width) 1fr; grid-template-rows: none; gap: 2vw; align-items: stretch; }

.main-panel {
  grid-column: 1; grid-row: 1 / 3;
  background: var(--dark-glass); backdrop-filter: blur(14px) saturate(0.8); -webkit-backdrop-filter: blur(14px) saturate(0.8);
  border: 1px solid var(--border-glass); border-radius: 2px; padding: 3rem 2.6rem;
  min-height: 92vh; max-height: 92vh; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(180,165,140,0.25) transparent;
  display: flex; flex-direction: column; gap: 2rem;
}
.main-panel::-webkit-scrollbar { width: 3px; }
.main-panel::-webkit-scrollbar-thumb { background: rgba(180,165,140,0.3); border-radius: 2px; }

.text-panel, .cal-panel {
  background: var(--dark-glass); backdrop-filter: blur(14px) saturate(0.8); -webkit-backdrop-filter: blur(14px) saturate(0.8);
  border: 1px solid var(--border-glass); border-radius: 2px; min-height: 92vh; max-height: 92vh;
}
.text-panel { padding: 3rem 2.6rem; display: flex; flex-direction: column; gap: 2rem; overflow-y: auto; }
.cal-panel { overflow: hidden; }
#cal-embed { width: 100%; height: 100%; min-height: 92vh; }

.panel-eyebrow {
  font-family: 'Lovely May', serif; font-size: 0.6rem; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--text-secondary); border-bottom: 1px solid var(--border-glass); padding-bottom: 1rem;
  text-decoration: none; display: block; transition: color 0.3s ease, letter-spacing 0.3s ease;
}
a.panel-eyebrow:hover { color: var(--text-primary); letter-spacing: 0.4em; }
.panel-body { font-size: clamp(0.95rem, 1.3vw, 1.08rem); line-height: 1.9; font-weight: 300; }
.panel-body p + p { margin-top: 1.4rem; }
.panel-body em { font-style: italic; color: rgba(210,200,180,0.85); }
.panel-body a { color: var(--text-secondary); text-decoration: none; border-bottom: 1px solid var(--border-glass); transition: color 0.3s ease; }
.panel-body a:hover { color: var(--text-primary); }

/* ── seed accordion: a clickable phrase parts the glass into a pane below ── */
.seed {
  font: inherit; line-height: inherit; color: rgba(239,180,92,0.78);
  background: none; border: none; padding: 0; cursor: pointer;
  border-bottom: 1px dotted rgba(239,180,92,0.45);
  transition: color 0.4s ease, border-color 0.4s ease, text-shadow 0.4s ease;
}
.seed:hover { color: #efb45c; border-bottom-color: #efb45c; text-shadow: 0 0 12px rgba(239,180,92,0.35); }
.seed:focus-visible { outline: none; color: #efb45c; }
.seed[aria-expanded="true"] {
  color: #efb45c; border-bottom-style: solid; text-shadow: 0 0 12px rgba(239,180,92,0.3);
}

/* poem lines as blocks, so a pane can open directly under the line that holds the seed */
.stanza { margin-top: 1.4rem; }
.stanza:first-child { margin-top: 0; }
.stanza .ln { display: block; }

/* the parting: rows collapse 0fr→1fr so the line above lifts and a full-width pane
   is revealed in the gap beneath it. The reading surface sits higher; the pane is
   recessed below it, with a shadow cast down into the gap from the lifted lip. */
.descent {
  display: grid; grid-template-rows: 0fr;
  margin: 0 -2.6rem;                 /* break out to the full panel width */
  transition: grid-template-rows 0.75s cubic-bezier(0.4, 0, 0.15, 1);
}
.descent.open { grid-template-rows: 1fr; }
.descent-inner { overflow: hidden; min-height: 0; }
.descent-body {
  margin: 0.85rem 0 0.55rem;          /* the gap — the parting you see into */
  padding: 1.7rem 2.6rem;
  background: rgba(5, 4, 3, 0.66);    /* recessed: darker than the reading surface */
  border-top: 1px solid rgba(239,180,92,0.10);
  /* shadow gap: the lifted upper lip casts down into the recess */
  box-shadow: inset 0 12px 16px -10px rgba(0,0,0,0.92),
              inset 0 -10px 14px -10px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(-5px);
  transition: opacity 0.55s ease 0.14s, transform 0.55s ease 0.14s;
}
.descent.open > .descent-inner > .descent-body { opacity: 1; transform: none; }
.descent-body p { font-size: 0.96em; color: var(--text-secondary); }
/* nesting reads as going further down a branch: a touch deeper each level */
.descent .descent-body { background: rgba(3, 2, 2, 0.72); }
.panel-footer {
  margin-top: auto; padding-top: 1.5rem; border-top: 1px solid var(--border-glass);
  font-family: 'Lovely May', serif; font-size: 0.55rem; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--text-secondary); display: flex; gap: 1.4rem; flex-wrap: wrap;
}
.panel-footer a { color: var(--text-secondary); text-decoration: none; transition: color 0.3s ease; }
.panel-footer a:hover { color: var(--text-primary); }

.nav-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none;
  color: var(--text-primary); background: var(--dark-glass);
  backdrop-filter: blur(14px) saturate(0.8); -webkit-backdrop-filter: blur(14px) saturate(0.8);
  border: 1px solid var(--border-glass); border-radius: 2px; transition: background 0.3s ease, border-color 0.3s ease;
}
.nav-box:hover { background: var(--dark-glass-hover); border-color: rgba(200, 185, 155, 0.28); }
.nav-svg { display: block; height: auto; opacity: 0.75; }
.nav-root-svg { display: block; width: 45px; height: auto; opacity: 0.75; }
.nav-branch { grid-column: 2; grid-row: 1; justify-self: start; align-self: start; margin-top: 2vh; margin-left: 6vw; padding: 1.2rem 1.6rem; }
.nav-branch .nav-svg { width: 140px; }
.nav-cross-unit { position: absolute; bottom: 3vh; left: calc(var(--panel-width) + 3vw - var(--overlap)); width: 80px; height: 44vh; min-height: 200px; }
.nav-root { position: absolute; top: 0; left: 0; width: 100%; height: 100%; align-items: center; justify-content: center; z-index: 2; padding: 1rem 0; }
.nav-root .nav-svg { width: 210px; max-width: none; transform: rotate(-90deg); }
.nav-hyphae { position: absolute; top: 72%; left: -20px; width: max-content; padding: 1.2rem 1.8rem; z-index: 3; }
.nav-hyphae .nav-svg { width: 160px; }
.nav-rooth-svg { display: none; }

.poem-pane, .map-pane, .back-link { position: relative; z-index: 1; }
.poem-pane {
  width: 100%; background: var(--dark-glass); backdrop-filter: blur(14px) saturate(0.8); -webkit-backdrop-filter: blur(14px) saturate(0.8);
  border-bottom: 1px solid var(--border-glass); padding: 2.4rem 6vw;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem 6vw;
}
.poem-eyebrow {
  grid-column: 1 / 3; font-family: 'Lovely May', serif; font-size: 0.6rem; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--text-secondary); border-bottom: 1px solid var(--border-glass); padding-bottom: 1rem; margin-bottom: 0.5rem;
}
.poem-col { font-size: clamp(0.95rem, 1.4vw, 1.1rem); line-height: 2; font-weight: 300; }
.poem-col p { margin-bottom: 1.2rem; } .poem-col p:last-child { margin-bottom: 0; }
.poem-col a { color: var(--text-secondary); text-decoration: none; font-style: italic; transition: color 0.3s ease; }
.poem-col a:hover { color: var(--text-primary); }
.map-pane { flex: 1; width: 100%; min-height: 62vh; position: relative; }
.back-link {
  position: fixed; top: 1.5rem; right: 2rem; font-family: 'Lovely May', serif; font-size: 0.6rem;
  letter-spacing: 0.3em; text-transform: uppercase; color: var(--text-secondary); text-decoration: none; z-index: 10; transition: color 0.3s ease;
}
.back-link:hover { color: var(--text-primary); }

@media (max-width: 700px) {
  :root { --panel-width: 100%; }
  .layout { display: flex; flex-direction: column; gap: 1rem; padding: 1.2rem 1rem; }
  .layout.split { gap: 1rem; }
  .main-panel { max-height: none; min-height: auto; overflow-y: visible; }
  .text-panel, .cal-panel { min-height: auto; }
  #cal-embed { min-height: 80vh; }
  .nav-branch { margin-left: 0; margin-top: 0; width: 100%; padding: 1.2rem; }
  .nav-branch .nav-svg { width: 120px; }
  .nav-cross-unit { position: static; width: 100%; height: auto; display: flex; flex-direction: column; gap: 1rem; }
  .nav-root, .nav-hyphae { position: static; width: auto; height: 100px; padding: 1.2rem; opacity: 1; }
  .nav-rooth-svg { display: block; height: 35px; width: auto; opacity: 0.8; }
  .nav-root-svg { display: none; }
  .nav-root .nav-svg { width: 60px; } .nav-hyphae .nav-svg { width: 140px; }
  .poem-pane { grid-template-columns: 1fr; padding: 2rem 1.4rem; gap: 0; }
  .poem-eyebrow { grid-column: 1; }
  .map-pane { min-height: 55vh; }
}

/* ── floating sophistication: lift the panels off the page ── */
.main-panel, .text-panel { box-shadow: 0 16px 54px rgba(0,0,0,0.42); }

/* ── crossword lattice (dog-whistle), injected by shell.js ── */
.lattice { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.lattice svg { position: absolute; }
.lattice text { font-family: 'Lovely May', serif; fill: #efb45c; text-anchor: middle; dominant-baseline: central; }
.lattice .grid { stroke: #c8bfb0; stroke-width: 0.5px; opacity: 0.05; fill: none; }
.lattice .lcell { fill: none; stroke: rgba(200,191,176,0.06); stroke-width: 0.5; }
@keyframes gutter { 0%, 100% { opacity: 0.16; } 50% { opacity: 0.05; } }
.lattice .lat { animation: gutter 4.4s ease-in-out infinite; }
@media (max-width: 700px) { .lattice { display: none; } }

/* ── nav sigil (crossword of destinations), injected by sigil.js ── */
/* The TEAHOUSE trunk lines up just right of the content pane's right edge. */
.sigil { position: fixed; left: calc(3vw + var(--panel-width) - 185px); bottom: 2vh; z-index: 100; }
.sigil-svg { width: 270px; height: auto; overflow: visible; }
.sigil .glyph {
  font-family: 'Lovely May', serif;
  font-weight: 400;
  font-size: 21px;
  letter-spacing: 0;
  fill: #efb45c;
  text-anchor: middle;
  dominant-baseline: central;
  transition: fill .3s ease, opacity .3s ease;
}
@keyframes sigil-gutter { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.16; } }
.sigil .glyph.flicker { animation: sigil-gutter 4.4s ease-in-out infinite; }
.sigil .glyph.lit { opacity: 1; animation: none; }
.sigil a.word { cursor: pointer; outline: none; }
.sigil a.word .hit { fill: transparent; }
.sigil a.word:focus { outline: none; }
.sigil a.word:focus-visible .hit { stroke: rgba(239,180,92,.5); stroke-width: 1; }
@media (max-width: 700px) {
  .sigil { left: 50%; right: auto; bottom: 2vh; transform: translateX(-50%); }
  .sigil-svg { width: min(90vw, 360px); }
}
