/* ==========================================================================
   PSYOURA: 2. BASE
   Reset, typography, layout primitives, the grain, the header and footer.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--s0);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* The grain. One fixed layer of very fine noise so the site feels like a
   surface rather than a screen. Deliberately near-subliminal. */
.grain {
  position: fixed; inset: 0; z-index: 90;
  pointer-events: none; opacity: .045; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -.008em;
  text-wrap: balance;
  margin: 0;
  color: var(--type);
}
h1 { font-size: var(--s5); }
h2 { font-size: var(--s4); }
h3 { font-size: var(--s2); }
h4 { font-size: var(--s1); }

p { margin: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--type); }:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: absolute; left: 0; top: 0; z-index: 200;
  background: var(--forest); color: var(--cream); padding: .7rem 1.1rem;
  transform: translateY(-120%);
  transition: transform 180ms var(--ease);
}
.skip-link:focus { transform: none; }

/* --------------------------------------------------------------------------
   LAYOUT
   -------------------------------------------------------------------------- */
.world {
  background-color: var(--ground);
  color: var(--type);
  padding-block: var(--sp7);
  position: relative;
  transition: background-color var(--world-fade) var(--ease);
}
.world--tight { padding-block: var(--sp6); }
.world--flush { padding-block: 0; }

.wrap {
  width: 100%; max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.15rem, 4vw, 3rem);
}
.wrap--narrow { max-width: 760px; }

.stack { display: flex; flex-direction: column; }
.g1 { gap: var(--sp1); } .g2 { gap: var(--sp2); } .g3 { gap: var(--sp3); }
.g4 { gap: var(--sp4); } .g5 { gap: var(--sp5); } .g6 { gap: var(--sp6); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1.6rem, 4vw, 3.6rem);
  align-items: start;
}
.split--wide { grid-template-columns: minmax(0, 1.35fr) minmax(0, .65fr); }
.split--center { align-items: center; }
@media (max-width: 880px) { .split, .split--wide { grid-template-columns: minmax(0, 1fr); } }
/* Grid and flex children refuse to shrink below their min-content by default,
   which pushed narrow phones sideways. This lets them shrink and wrap instead. */
.split > *, .stack > * { min-width: 0; }

/* The margin column: real annotations, as in a book */
.ruled {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.4rem);
  align-items: start;
}
.ruled > .margin { position: sticky; top: calc(var(--header-h) + 2rem); }
@media (max-width: 880px) {
  .ruled { grid-template-columns: 1fr; }
  .ruled > .margin { position: static; }
}

.head { display: flex; flex-direction: column; gap: var(--sp2); max-width: 46ch; margin-bottom: var(--sp5); }

/* --------------------------------------------------------------------------
   TYPE DEVICES
   -------------------------------------------------------------------------- */
.eyebrow {
  font-size: var(--s--2); text-transform: uppercase; letter-spacing: .22em;
  font-weight: 600; color: var(--accent); margin: 0;
}
.lede { font-size: var(--s2); line-height: 1.45; color: var(--soft); font-weight: 300; max-width: 40ch; }
.prose { max-width: var(--measure); color: var(--soft); }
.prose p + p { margin-top: var(--sp3); }
.prose strong { color: var(--type); font-weight: 600; }
.prose ul { padding-left: 1.1rem; margin: var(--sp3) 0 0; }
.prose li + li { margin-top: .45rem; }
.prose h3 { color: var(--type); margin-top: var(--sp5); margin-bottom: var(--sp2); }

.small { font-size: var(--s--1); }
.faint { color: var(--faint); }
.muted { color: var(--soft); }
.center { text-align: center; }

/* The hand: only where a person would actually scribble */
.hand { font-family: var(--hand); font-size: 1.45rem; line-height: 1.3; color: var(--accent); }
.hand--lg { font-size: 1.85rem; }
.tilt { display: inline-block; transform: rotate(-2deg); }
/* A rotated block is wider than its box, so on narrow phones it stuck out. */
@media (max-width: 430px) { .tilt { transform: none; } }

.rule { border: 0; height: 1px; background: var(--rule); margin: 0; }

/* --------------------------------------------------------------------------
   DOODLES
   -------------------------------------------------------------------------- */
.dd { color: var(--accent-dec); fill: none; stroke: currentColor; overflow: visible; }
.dd--pencil { stroke-width: 2.8; opacity: .45; }
.dd--ink    { stroke-width: 1.7; }
.dd--marker { stroke-width: 4.2; opacity: .3; }
.dd--moss  { color: var(--moss); }  .dd--fern { color: var(--fern); }
.dd--leaf  { color: var(--leaf); }  .dd--gold { color: var(--gold); }
.dd--clay  { color: var(--clay); }  .dd--mist { color: var(--mist); }
.dd--cream { color: var(--cream); }

/* Decorative marks placed in the corners of a section */
.deco { position: absolute; pointer-events: none; z-index: 0; opacity: .8; }
.world > .wrap { position: relative; z-index: 1; }

/* --------------------------------------------------------------------------
   HEADER
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 70;
  background: color-mix(in srgb, var(--forest) 94%, transparent);
  color: var(--cream);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #2B5548;
}
.site-header__inner {
  min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp4);
}
.logo {
  font-family: var(--display); font-size: 1.18rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--cream); text-decoration: none;
  display: inline-flex; align-items: center; gap: .55rem; white-space: nowrap;
}
.logo:hover { color: var(--leaf); }
/* The real logo mark. It takes the colour of the header it sits in, so one
   file serves the dark green home header and every cream page. */
.logo__mark { width: 34px; height: 34px; flex: none; color: currentColor; }
.logo__seed { width: 16px; height: 20px; color: var(--leaf); flex: none; }

.nav { display: flex; align-items: center; gap: clamp(.7rem, 1.7vw, 1.55rem); }
.nav__list { display: flex; align-items: center; gap: clamp(.7rem, 1.7vw, 1.55rem); list-style: none; margin: 0; padding: 0; }
.nav__link {
  font-size: var(--s--1); color: #C3CFB9; text-decoration: none;
  padding-block: .3rem; position: relative; white-space: nowrap;
}
.nav__link:hover { color: var(--cream); }
.nav__link[aria-current="page"] { color: var(--leaf); }
.nav__link[aria-current="page"]:after {
  content: ""; position: absolute; left: -2px; right: -2px; bottom: -2px; height: 6px;
  background: var(--leaf);
  -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 8'><path d='M2 5 Q14 2 27 4 T52 4 T76 5 T98 3' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>") no-repeat center/100% 100%;
          mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 8'><path d='M2 5 Q14 2 27 4 T52 4 T76 5 T98 3' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>") no-repeat center/100% 100%;
}
.header-actions { display: flex; align-items: center; gap: .6rem; flex: none; }
.nav-toggle {
  display: none; background: transparent; border: 1px solid #3E6D5C; color: var(--cream);
  padding: .45rem .75rem; font-family: var(--body); font-size: var(--s--2);
  letter-spacing: .1em; text-transform: uppercase; cursor: pointer;
  border-radius: 11px 9px 12px 8px;
}
@media (max-width: 1020px) {
  .nav-toggle { display: inline-block; }
  .nav {
    position: absolute; top: 100%; left: 0; right: 0; display: none;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--forest); border-bottom: 1px solid #2B5548;
    padding: var(--sp2) clamp(1.15rem, 4vw, 3rem) var(--sp4);
    max-height: 78vh; overflow-y: auto;
  }
  .nav.is-open { display: flex; }
  .nav__list { flex-direction: column; align-items: stretch; gap: 0; }
  .nav__list li { border-bottom: 1px solid #24493D; }
  .nav__link { display: block; padding: .9rem 0; font-size: var(--s1); }
  .nav__link[aria-current="page"]:after { display: none; }
}
@media (max-width: 640px) { .btn__long { display: none; } .logo { font-size: 1rem; letter-spacing: .15em; } }
/* Narrow phones (360px and under). The header is logo + button + menu, and at
   full size those three add up to more than the screen, which pushed every page
   sideways by about 12px. Everything here just tightens that one row. */
@media (max-width: 430px) {
  .site-header__inner { gap: .5rem; }
  .logo { font-size: .92rem; letter-spacing: .12em; gap: .4rem; }
  .logo__mark { width: 26px; height: 26px; }
  .header-actions { gap: .4rem; }
  .header-actions .btn { padding-inline: .7rem; font-size: var(--s--2); }
  .nav-toggle { padding: .45rem .55rem; }
}

/* --------------------------------------------------------------------------
   FOOTER
   -------------------------------------------------------------------------- */
.site-footer { background: var(--cosmic); color: var(--cream); padding-block: var(--sp6) var(--sp4); font-size: var(--s--1); }
.site-footer a { color: #CBD8C6; text-decoration: none; }
.site-footer a:hover { color: var(--gold); text-decoration: underline; }
.site-footer .logo { color: var(--cream); }

.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr; gap: var(--sp5) var(--sp4); }
@media (max-width: 1000px) { .footer-grid { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 640px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-grid h2 {
  font-family: var(--body); font-size: var(--s--2); text-transform: uppercase;
  letter-spacing: .18em; font-weight: 700; color: #8FA694; margin-bottom: var(--sp3);
}
.footer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.footer-bottom {
  margin-top: var(--sp5); padding-top: var(--sp4); border-top: 1px solid #234240;
  display: flex; flex-wrap: wrap; gap: var(--sp3); justify-content: space-between;
  color: #8FA694; font-size: var(--s--2);
}
.footer-line { font-family: var(--hand); font-size: 1.5rem; color: var(--gold); }

.emergency-strip {
  background: #0B1F1F; color: #D8E2D5; font-size: var(--s--2);
  padding-block: var(--sp3); border-top: 1px solid #234240;
}
.emergency-strip p { max-width: 92ch; margin-inline: auto; text-align: center; }
.emergency-strip strong { color: var(--gold); }

/* --------------------------------------------------------------------------
   UTILITIES
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.mt2 { margin-top: var(--sp2); } .mt3 { margin-top: var(--sp3); }
.mt4 { margin-top: var(--sp4); } .mt5 { margin-top: var(--sp5); }
.mt6 { margin-top: var(--sp6); }

/* The header borrows the colour of the page you are on, so moving through the
   menu actually changes the room rather than only the content below it. */
[data-site-world] .site-header {
  background: color-mix(in srgb, var(--site-ground, var(--forest)) 94%, transparent);
  border-bottom-color: color-mix(in srgb, var(--site-accent, #2B5548) 32%, transparent);
  transition: background-color 700ms var(--ease), border-color 700ms var(--ease);
}
[data-site-world] .site-header,
[data-site-world] .site-header .logo,
[data-site-world] .nav__link,
[data-site-world] .nav-toggle { color: var(--site-type, var(--cream)); }
[data-site-world] .nav__link[aria-current="page"] { color: var(--site-accent, var(--gold)); }

/* A button is a flex row with a gap, for the arrow doodle. Two text nodes in
   one button therefore got that gap between the words, which read as a hole
   after "See". One span keeps the whole label as a single flex item. */
.btn__label { display: inline; }

/* Several components set display, which beats the browser's own rule for the
   hidden attribute. Without this, hiding something in JS does nothing. */
[hidden] { display: none !important; }

/* Very narrow phones (320px, an old iPhone SE or a folded screen). Nothing
   structural changes, these just stop the longest words and the header row
   from pushing the page sideways. */
@media (max-width: 365px) {
  .logo { font-size: .8rem; letter-spacing: .08em; }
  .logo__mark { width: 22px; height: 22px; }
  .header-actions .btn { padding-inline: .55rem; }
  .nav-toggle { padding: .45rem .45rem; }
  .hand--lg { font-size: 1.5rem; }
  h1, h2 { overflow-wrap: break-word; }
  .setup-note__title, .matgroup__head h2 { overflow-wrap: anywhere; }
}
