/* Darkfield Almanac — nested CSS, container-query driven */
:root {
  --night: #0a0f24;
  --dusk: #141b3a;
  --haze: #1f2852;
  --edge: #2e3a6e;
  --star: #f4efe2;
  --mist: #aab3d6;
  --amber: #f0b44c;
  --rose: #ff7b7b;
  --sans: "Futura", "Century Gothic", "Trebuchet MS", sans-serif;
  --body: "Optima", "Candara", "Segoe UI", "Noto Sans", sans-serif;
  --round: 22px;
  color-scheme: dark;
}
:root[data-redlight] {
  --night: #120000; --dusk: #1c0303; --haze: #2a0606; --edge: #4a0e0e;
  --star: #ff8f8f; --mist: #d46a6a; --amber: #ff6b6b; --rose: #ff6b6b;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 1.5rem; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 80% -10%, var(--haze), transparent 60%), var(--night);
  color: var(--star);
  font: 1.08rem/1.7 var(--body);
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
img, svg { display: block; max-width: 100%; }
a { color: var(--amber); text-underline-offset: 3px; &:hover { color: var(--star); } }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; border-radius: 6px; }
h1, h2, h3 {
  font-family: var(--sans); font-weight: 500; letter-spacing: .01em; line-height: 1.12; margin: 0 0 .55em;
}
h1 { font-size: clamp(2.3rem, 5vw, 3.9rem); }
h2 { font-size: clamp(1.7rem, 3vw, 2.4rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }

.to-content {
  position: absolute; left: -9999px; top: 1rem; z-index: 99; background: var(--amber); color: var(--night); padding: .7rem 1rem; border-radius: 8px;
  &:focus { left: 1rem; }
}

/* shell: sidebar + content */
.frame { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; }
@media (max-width: 960px) { .frame { grid-template-columns: 1fr; } }

site-nav { display: block; }
.rail {
  position: sticky; top: 0; height: 100vh; padding: 2rem 1.5rem; border-right: 1px solid var(--edge);
  background: color-mix(in srgb, var(--night) 85%, transparent);
  display: flex; flex-direction: column; gap: 2rem;
  @media (max-width: 960px) { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--edge); padding: 1rem 1.25rem; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
}
.logo {
  display: flex; align-items: center; gap: .7rem; color: var(--star); text-decoration: none; font: 500 1.2rem var(--sans); letter-spacing: .04em;
  & svg { width: 44px; height: 44px; }
}
.rail-toggle {
  display: none; min-height: 44px; padding: 0 1rem; background: var(--dusk); color: var(--star); border: 1px solid var(--edge); border-radius: 999px; font: 500 .95rem var(--sans); cursor: pointer;
  @media (max-width: 960px) { display: inline-flex; align-items: center; }
}
.rail-links {
  list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem;
  & a {
    display: flex; align-items: center; gap: .7rem; min-height: 46px; padding: 0 1rem; border-radius: 12px; color: var(--mist); text-decoration: none; font: 500 1rem var(--sans);
    &:hover { background: var(--dusk); color: var(--star); }
    &[aria-current="page"] { background: var(--haze); color: var(--star); box-shadow: inset 3px 0 0 var(--amber); }
  }
  @media (max-width: 960px) { display: none; width: 100%; &[data-open] { display: grid; } }
}
.redlight {
  margin-top: auto; display: flex; align-items: center; gap: .8rem; min-height: 46px; padding: 0 1rem; border: 1px solid var(--edge); border-radius: 999px; background: none; color: var(--star); font: 500 .92rem var(--sans); cursor: pointer;
  &::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--rose); box-shadow: 0 0 10px var(--rose); }
  &[aria-pressed="true"] { background: var(--haze); }
  @media (max-width: 960px) { display: none; .rail-links[data-open] ~ & { display: flex; width: 100%; } }
}

/* content area */
.stage { container-type: inline-size; container-name: stage; min-width: 0; }
.band { padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 5vw, 4rem); }
.band--lift { background: linear-gradient(180deg, transparent, var(--dusk)); }
.band--panel { background: var(--dusk); border-block: 1px solid var(--edge); }
.limit { max-width: 1060px; }
.limit-text { max-width: 720px; }
.overline { font: 500 .8rem var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--amber); margin-bottom: .9rem; display: block; }
.lede { font-size: 1.22rem; color: var(--mist); max-width: 38em; }

/* hero */
.opening {
  display: grid; gap: 2.5rem; align-items: center;
  @container stage (min-width: 820px) { grid-template-columns: 1.15fr .85fr; }
}
.skyplate {
  border-radius: 50%; aspect-ratio: 1; border: 1px solid var(--edge); background: var(--night); padding: 0; overflow: hidden;
  max-width: 420px; width: 100%; justify-self: center;
}
.skyplate img, .page-photo { width: 100%; object-fit: cover; display: block; }
.skyplate img { height: 100%; }
.page-photo { height: min(42vh, 320px); margin: 1.2rem 0; }
.photo-credit { display: block; max-width: 40rem; font-size: .75rem; color: var(--mist); margin-top: .35rem; }
.pill {
  display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 0 1.5rem; border-radius: 999px; font: 500 1rem var(--sans); text-decoration: none; cursor: pointer; border: 1px solid transparent;
  &.pill--glow { background: var(--amber); color: #1a1405; box-shadow: 0 0 30px color-mix(in srgb, var(--amber) 35%, transparent); &:hover { background: var(--star); color: var(--night); } }
  &.pill--ghost { border-color: var(--edge); color: var(--star); &:hover { background: var(--dusk); border-color: var(--mist); color: var(--star); } }
}
.pills { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.8rem; }

/* tonight panel */
.tonight {
  display: grid; gap: 1rem;
  @container stage (min-width: 700px) { grid-template-columns: repeat(3, 1fr); }
  & > div { background: var(--night); border: 1px solid var(--edge); border-radius: var(--round); padding: 1.6rem; }
  & strong { display: block; font: 500 .78rem var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--amber); margin-bottom: .5rem; }
}

/* tile grid */
.tiles {
  display: grid; gap: 1.2rem; margin-top: 2rem;
  @container stage (min-width: 640px) { grid-template-columns: repeat(2, 1fr); }
  @container stage (min-width: 1000px) { grid-template-columns: repeat(3, 1fr); }
}
.tile {
  background: var(--dusk); border: 1px solid var(--edge); border-radius: var(--round); padding: 1.5rem; display: flex; flex-direction: column;
  & svg { width: 100%; height: 130px; margin-bottom: 1rem; }
  & .when { font: .85rem var(--sans); color: var(--mist); letter-spacing: .06em; }
  & a.go { margin-top: auto; padding-top: .8rem; font: 500 .95rem var(--sans); }
}

/* moon phases strip */
.phases {
  display: flex; gap: 1.2rem; overflow-x: auto; padding-bottom: .5rem; margin-top: 1.6rem;
  & figure { margin: 0; min-width: 120px; text-align: center; color: var(--mist); font: .85rem var(--sans); }
  & svg { width: 64px; height: 64px; margin: 0 auto .5rem; }
}

/* FAQ */
.faq-list { margin-top: 1.5rem; display: grid; gap: .7rem; }
.faq-list details {
  background: var(--dusk); border: 1px solid var(--edge); border-radius: 16px; padding: 0 1.3rem;
  & summary { cursor: pointer; list-style: none; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; font: 500 1.05rem var(--sans); }
  & summary::-webkit-details-marker { display: none; }
  & summary::after { content: "✦"; color: var(--amber); transition: transform .2s; }
  &[open] summary::after { transform: rotate(45deg); }
  & p { color: var(--mist); }
}

/* long form */
.guide {
  display: grid; gap: 3rem;
  @container stage (min-width: 1000px) { grid-template-columns: 230px minmax(0, 1fr); }
}
.waypoints {
  align-self: start; background: var(--dusk); border: 1px solid var(--edge); border-radius: var(--round); padding: 1.3rem; font: .95rem var(--sans);
  @container stage (min-width: 1000px) { position: sticky; top: 1.5rem; }
  & ol { margin: .6rem 0 0; padding-left: 1.2rem; }
  & li { margin: .3rem 0; }
}
.reading {
  max-width: 740px;
  & h2 { margin-top: 2.4em; padding-top: 1rem; border-top: 1px solid var(--edge); &:first-child { margin-top: 0; border: 0; padding: 0; } }
  & h3 { margin-top: 1.8em; }
  & ul, & ol { padding-left: 1.3rem; }
  & li { margin-bottom: .45em; }
}
.datatable {
  overflow-x: auto; margin: 1.5rem 0 2rem; border: 1px solid var(--edge); border-radius: 14px;
  & table { border-collapse: collapse; width: 100%; font-size: .98rem; }
  & th, & td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--edge); vertical-align: top; }
  & th { font: 500 .8rem var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--amber); background: var(--dusk); }
  & tr:last-child td { border-bottom: 0; }
}
.hint {
  background: var(--dusk); border: 1px solid var(--edge); border-left: 4px solid var(--amber); border-radius: 12px; padding: 1rem 1.2rem; margin: 1.5rem 0;
  &.hint--caution { border-left-color: var(--rose); }
  & p:last-child { margin: 0; }
}

/* constellation profiles */
.skipnav { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem;
  & a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border: 1px solid var(--edge); border-radius: 999px; color: var(--star); text-decoration: none; font: .9rem var(--sans); &:hover { border-color: var(--amber); color: var(--amber); } }
}
.object {
  display: grid; gap: 1.5rem; padding: 2.4rem 0; border-top: 1px solid var(--edge); scroll-margin-top: 1rem;
  @container stage (min-width: 720px) { grid-template-columns: 170px 1fr; gap: 2.5rem; }
  & svg { width: 170px; height: 170px; @container stage (max-width: 719px) { width: 120px; height: 120px; } }
  & dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1.2rem; margin: 1rem 0 0; font-size: .95rem; }
  & dt { font: 500 .8rem var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--amber); padding-top: .15rem; }
  & dd { margin: 0; color: var(--mist); }
}

/* contact form */
mail-form { display: block; }
.ask {
  display: grid; gap: 1.2rem; background: var(--dusk); border: 1px solid var(--edge); border-radius: var(--round); padding: clamp(1.4rem, 4vw, 2.2rem);
  & label { display: block; font: 500 .92rem var(--sans); margin-bottom: .4rem; }
  & :is(input[type=text], input[type=email], select, textarea) {
    width: 100%; min-height: 50px; padding: .75rem 1rem; border-radius: 12px; border: 1px solid #5866a3; background: var(--night); color: var(--star); font: inherit;
    &:focus { outline: 3px solid var(--amber); outline-offset: 1px; }
  }
  & textarea { min-height: 160px; resize: vertical; }
  & .agree { display: flex; gap: .7rem; align-items: flex-start; & input { width: 20px; height: 20px; margin-top: .3rem; accent-color: var(--amber); } & label { font: 1rem var(--body); margin: 0; } }
  & .note { font-size: .9rem; color: var(--mist); margin: .35rem 0 0; }
  & .err { display: none; color: var(--rose); font-size: .92rem; margin: .35rem 0 0; }
  & [aria-invalid="true"] { border-color: var(--rose) !important; }
  & .field[data-bad] .err { display: block; }
  & [role=status] { display: none; padding: 1rem; border-radius: 12px; background: var(--haze); border: 1px solid var(--amber); font-weight: 600; &[data-on] { display: block; } }
}

/* footer */
.foot {
  border-top: 1px solid var(--edge); padding: 3rem clamp(1.25rem, 5vw, 4rem) 2rem; color: var(--mist); font-size: .95rem; container-type: inline-size;
  & .cols { display: grid; gap: 2rem; @container (min-width: 760px) { grid-template-columns: 1.6fr 1fr 1fr 1fr; } }
  & h2 { font: 500 .78rem var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--amber); margin-bottom: .7rem; }
  & ul { list-style: none; padding: 0; margin: 0; }
  & li a, & li button { display: inline-flex; align-items: center; min-height: 38px; color: var(--star); text-decoration: none; &:hover { color: var(--amber); } }
  & button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
  & .fine { border-top: 1px solid var(--edge); margin-top: 2rem; padding-top: 1.2rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; font-size: .85rem; }
}

/* consent: right-side drawer */
consent-panel { display: contents; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); z-index: 70; background: var(--dusk); border-left: 1px solid var(--edge);
  box-shadow: -20px 0 60px rgba(0, 0, 0, .5); padding: 2rem 1.6rem; overflow-y: auto;
  transform: translateX(105%); visibility: hidden; transition: transform .3s ease, visibility .3s;
  &[data-visible] { transform: none; visibility: visible; }
  & h2 { font-size: 1.6rem; }
  & p { color: var(--mist); font-size: .98rem; }
  & .stack { display: grid; gap: .7rem; margin-top: 1.4rem; }
  & .pill { width: 100%; }
  & .choices { margin-top: 1.6rem; border-top: 1px solid var(--edge); padding-top: 1rem; display: none; &[data-visible] { display: block; } }
  & .row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--edge); }
  & .row span { display: block; font-size: .88rem; color: var(--mist); }
  & [role=switch] {
    position: relative; flex-shrink: 0; width: 52px; height: 30px; border-radius: 999px; border: 1px solid var(--edge); background: var(--night); cursor: pointer;
    &::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--mist); transition: transform .2s; }
    &[aria-checked="true"] { background: var(--amber); &::after { transform: translateX(22px); background: var(--night); } }
    &[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
  }
}
