/* ============================================================================
   THE HOUSE THAT WALKS — the margin notes
   The same ink, the same paper, the same two typefaces as the game itself.
   Nothing here is decoration for its own sake: the palette is lifted verbatim
   from hw.css so the site and the game are visibly the same object.
   ========================================================================== */

:root {
  --ink: #14130d;
  --ink-soft: #4a4638;
  --paper: #ece5d3;
  --paper-deep: #ddd5c0;
  --accent: #a83a24;
  --accent-text: #8f2f1c;
  --gold: #b8893a;
  --gold-text: #7d5c22;
  --hair: rgba(20, 19, 13, 0.16);
  --serif: Georgia, "Times New Roman", serif;
  --mono: "Courier New", ui-monospace, monospace;

  --rule: 1px;
  --gutter: clamp(20px, 6vw, 64px);
  --measure: 62ch;
}

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* The paper. Two layers of very low-contrast noise, fixed so it reads as the
   sheet the page is printed on rather than something that scrolls with it. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(20, 19, 13, 0.05) 0 1px, transparent 1px),
    radial-gradient(circle at 72% 58%, rgba(20, 19, 13, 0.04) 0 1px, transparent 1px),
    radial-gradient(circle at 44% 86%, rgba(20, 19, 13, 0.03) 0 1px, transparent 1px);
  background-size: 37px 41px, 53px 47px, 29px 31px;
}

/* A faint vignette, the same idea as the renderer's drawVignette(). */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(20, 19, 13, 0.10) 100%);
}

main, header, footer { position: relative; z-index: 1; }

::selection { background: var(--accent); color: var(--paper); }

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

/* ── typographic scale ──────────────────────────────────────────────────── */

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

h1 {
  font-family: var(--serif);
  font-weight: normal;
  font-size: clamp(38px, 9vw, 92px);
  line-height: 0.98;
  letter-spacing: -0.022em;
}

h2 {
  font-family: var(--serif);
  font-weight: normal;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.14;
  letter-spacing: -0.012em;
}

h3 {
  font-family: var(--mono);
  font-weight: normal;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.lede {
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.56;
  color: var(--ink-soft);
  max-width: 46ch;
}

.mono { font-family: var(--mono); }

em { font-style: italic; color: var(--accent-text); }

/* A rule that looks drawn rather than printed: it fades at both ends. */
.rule {
  height: var(--rule);
  border: none;
  background: linear-gradient(90deg, transparent, var(--hair) 12%, var(--hair) 88%, transparent);
}

/* ── the page frame ─────────────────────────────────────────────────────── */

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* A thin standing rule down the left of the whole page, like a ruled margin
   on a notebook. Hidden narrow, where there is no margin to rule. */
@media (min-width: 900px) {
  body { border-left: none; }
  .wrap::before {
    content: '';
    position: absolute;
    left: calc(var(--gutter) - 22px);
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--hair);
  }
  .wrap { position: relative; }
}

section { padding: clamp(64px, 11vh, 132px) 0; }

/* ── masthead ───────────────────────────────────────────────────────────── */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(236, 229, 211, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hair);
}

.masthead .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 62px;
}

.mark {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.mark svg { display: block; width: 22px; height: 22px; }

nav.links {
  display: flex;
  gap: clamp(14px, 2.4vw, 30px);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

nav.links a { position: relative; padding-bottom: 3px; }

nav.links a::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.34s cubic-bezier(0.2, 0.7, 0.2, 1);
}

nav.links a:hover { color: var(--ink); }
nav.links a:hover::after { transform: scaleX(1); }

/* ── hero ───────────────────────────────────────────────────────────────── */

.hero {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: clamp(28px, 5vw, 76px);
  align-items: center;
  padding-top: clamp(52px, 9vh, 104px);
  padding-bottom: clamp(52px, 9vh, 104px);
}

.hero-copy > * + * { margin-top: 22px; }

.title-mark {
  display: block;
  font-size: clamp(38px, 8.4vw, 88px);
}

.title-mark .turn {
  display: inline-block;
  color: var(--accent-text);
}

/* ── the turning room ───────────────────────────────────────────────────────
   The one piece of motion on the page, and it is the game's whole idea: a
   quarter turn, and the wall you were beside becomes the floor you stand on.
   It turns on click and on a slow timer, never continuously — a thing that
   spins forever is wallpaper, a thing that turns once is a demonstration. */

.stage {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
  border: 1px solid var(--hair);
  background: var(--paper-deep);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 18px 44px -30px rgba(20, 19, 13, 0.55);
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

.stage svg { display: block; width: 100%; height: 100%; }

/* The room turns; the house stays upright relative to the new floor, which is
   exactly what happens in game. */
#room {
  transform-origin: 50% 50%;
  transition: transform 1.05s cubic-bezier(0.62, 0.02, 0.2, 1);
}

.stage-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9px;
  text-align: center;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.72;
  pointer-events: none;
}

.stage:hover .stage-hint { color: var(--accent-text); opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  #room { transition: none; }
  html { scroll-behavior: auto; }
}

/* ── the numbers ────────────────────────────────────────────────────────── */

.figures {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--hair);
  border: 1px solid var(--hair);
}

.figure {
  background: var(--paper);
  padding: clamp(18px, 2.6vw, 30px) clamp(14px, 2vw, 24px);
}

.figure b {
  display: block;
  font-family: var(--serif);
  font-weight: normal;
  font-size: clamp(26px, 3.6vw, 44px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.figure span {
  display: block;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ── the three claims ───────────────────────────────────────────────────── */

.claims {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: clamp(26px, 4vw, 54px);
  margin-top: 44px;
}

.claim > h3 { margin-bottom: 12px; }
.claim p { color: var(--ink-soft); }
.claim p + p { margin-top: 12px; }

/* ── plates: the screenshots, hung like prints ───────────────────────────── */

.plates {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(20px, 3.4vw, 44px);
  margin-top: 44px;
}

figure.plate { margin: 0; }

figure.plate .frame {
  border: 1px solid var(--hair);
  background: var(--paper-deep);
  padding: 7px;
  box-shadow: 0 14px 34px -26px rgba(20, 19, 13, 0.6);
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1),
              box-shadow 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

figure.plate:hover .frame {
  transform: translateY(-4px);
  box-shadow: 0 22px 44px -26px rgba(20, 19, 13, 0.66);
}

figure.plate img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--hair);
}

figure.plate figcaption {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
}

figure.plate figcaption b {
  font-weight: normal;
  color: var(--accent-text);
  letter-spacing: 0.18em;
  white-space: nowrap;
}

/* ── the promise strip: what this game will never do ─────────────────────── */

.nevers { margin-top: 40px; border-top: 1px solid var(--hair); }

.never {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 16px;
  align-items: baseline;
  padding: 18px 0;
  border-bottom: 1px solid var(--hair);
}

.never .no {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent-text);
  line-height: 1.3;
}

.never p { color: var(--ink-soft); }
.never p b { font-weight: normal; color: var(--ink); }

/* ── prose pages (the privacy policy) ───────────────────────────────────── */

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 20px; }
.prose h2 { margin-top: 52px; }
.prose h2:first-child { margin-top: 0; }
.prose ul { padding-left: 1.1em; }
.prose li { margin-top: 8px; color: var(--ink-soft); }
.prose p { color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: normal; border-bottom: 1px solid var(--hair); }

.prose a.ext {
  color: var(--accent-text);
  border-bottom: 1px solid rgba(168, 58, 36, 0.35);
}
.prose a.ext:hover { border-bottom-color: var(--accent); }

.stamp {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 12px;
  border: 1px solid var(--hair);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ── footer ─────────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--hair);
  padding: clamp(38px, 7vh, 72px) 0 clamp(30px, 5vh, 54px);
}

.foot {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(22px, 5vw, 64px);
  justify-content: space-between;
  align-items: flex-start;
}

.foot h3 { margin-bottom: 10px; }

.foot a.mail {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent-text);
  border-bottom: 1px solid rgba(168, 58, 36, 0.3);
}
.foot a.mail:hover { border-bottom-color: var(--accent); }

.foot nav {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
}
.foot nav a:hover { color: var(--accent-text); }

.colophon {
  margin-top: clamp(30px, 5vh, 54px);
  padding-top: 18px;
  border-top: 1px solid var(--hair);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
}

/* ── entrance: one fade, once, per block ─────────────────────────────────────
   The hidden state is gated on `html.anim`, which site.js adds from inside a
   requestAnimationFrame callback — so it is only ever applied by a browser that
   is genuinely painting frames. This is not belt-and-braces: an opacity
   TRANSITION needs frames to advance, so in a tab that is not compositing the
   class would be added, the transition would never run, and the whole page
   would sit at opacity 0 while looking, in the DOM, perfectly correct. Hiding
   content is the risky half, so the risky half is what gets gated. */

html.anim .reveal {
  opacity: 0;
  transform: translateY(14px);
}

html.anim .reveal {
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

html.anim .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html.anim .reveal { opacity: 1; transform: none; transition: none; }
  figure.plate .frame { transition: none; }
}

/* ── narrow ─────────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .stage { order: -1; max-width: 380px; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .plates { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  body { font-size: 16px; }
  nav.links { gap: 12px; font-size: 9px; }
  .mark span { display: none; }
  .figure b { font-size: 27px; }
}

/* ── print: the policy should print cleanly, since somebody will ─────────── */

@media print {
  body::before, body::after, .masthead, .stage, footer nav { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .prose { max-width: none; }
  a.ext::after { content: ' (' attr(href) ')'; font-family: var(--mono); font-size: 9pt; }
}
