/* Deed to the Keep - the look comes from the game's own UI (data/ui.json theme): dark oak panels with brass edges,
   parchment books, the red wax DEED seal, and the gloomy-blue-to-golden light of a room being restored. */
@font-face { font-family: "Fraunces"; src: url("/fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/fonts/nunito.woff2") format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  --night: #17110C;       /* the dark behind the game's panels */
  --panel: #221812;       /* ui.json panel */
  --panel-hi: #3A2B1F;    /* ui.json panel_hi */
  --edge: #7A5A36;        /* ui.json edge (brass-brown frame) */
  --edge-hi: #C8913A;
  --gold: #F2C46D;        /* ui.json gold */
  --text-light: #F6E9CF;  /* ui.json text */
  --muted-light: #BFAE90; /* ui.json muted */
  --parchment: #EFE2C4;   /* ui.json parchment (the Journal) */
  --parchment-2: #E5D3AC;
  --parchment-edge: #B8976A;
  --ink: #24170F;         /* ui.json ink */
  --ink-soft: #5E4A36;
  --seal: #9E2F24;        /* ui.json seal (the DEED stamp) */
  --seal-hi: #D7704F;
  --gloom: #1E2446;       /* a room as found */
  --magic: #6FE3D6;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--night); color: var(--text-light);
  font-family: var(--sans); font-size: 1.125rem; line-height: 1.6;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--gold); }
:focus-visible { outline: 3px solid var(--magic); outline-offset: 3px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: var(--ink); padding: .5rem 1rem; z-index: 10; font-weight: 800; }
.skip:focus { left: 1rem; top: 1rem; }

.wrap { max-width: 1120px; margin: 0 auto; padding-inline: max(20px, env(safe-area-inset-left)); }
.narrow { max-width: 760px; }
section { padding-block: clamp(3.5rem, 8vw, 6rem); position: relative; }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0 0 .75rem; text-wrap: balance; }
h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-variation-settings: "opsz" 72; }
h3 { font-size: 1.2rem; color: var(--gold); }
p { margin: 0 0 1rem; }
.kicker {
  font-weight: 900; font-size: .8rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold); margin-bottom: .6rem;
}
.lede { font-size: clamp(1.15rem, 2.2vw, 1.35rem); }

/* castle battlements along the top edge of a section, in that section's own colour */
.battlements::before {
  content: ""; position: absolute; left: 0; right: 0; top: -15px; height: 15px;
  background: linear-gradient(90deg, var(--bg) 0 50%, transparent 50% 100%);
  background-size: 48px 15px;
}

/* ---------- hero ---------- */
.hero {
  position: relative; min-height: 600px; display: grid; place-items: center; overflow: hidden;
  background: #C9A877;
}
.hero picture, .hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-bg { object-fit: cover; object-position: 50% 45%; }
.hero::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 50% 42%, rgba(23,17,12,.5) 0%, rgba(23,17,12,.2) 100%),
    linear-gradient(180deg, rgba(23,17,12,.45) 0%, rgba(23,17,12,.15) 45%, rgba(23,17,12,.85) 100%);
}
.hero-inner { position: relative; z-index: 1; text-align: center; padding: calc(3rem + env(safe-area-inset-top)) 20px 3.5rem; }
.hero h1 { margin: 0 auto 1.4rem; max-width: 760px; }
.hero h1 img { width: 100%; filter: drop-shadow(0 4px 2px rgba(23,17,12,.55)) drop-shadow(0 10px 28px rgba(23,17,12,.6)); }
.slip {
  display: inline-flex; align-items: center; gap: .7rem; flex-wrap: wrap; justify-content: center;
  background: var(--parchment); color: var(--ink); font-family: var(--serif); font-weight: 600;
  font-size: clamp(1.05rem, 2.6vw, 1.35rem); padding: .45rem 1.1rem .45rem .45rem; border-radius: 3px;
  border: 1px solid var(--parchment-edge); box-shadow: 0 8px 22px rgba(0,0,0,.4); transform: rotate(-1deg);
  margin: 0 0 1.6rem; max-width: 100%;
}
.slip span {
  background: var(--seal); color: var(--parchment); font-family: var(--sans); font-weight: 900; font-size: .72rem;
  letter-spacing: .14em; text-transform: uppercase; padding: .25rem .6rem; border-radius: 2px;
}
.status {
  display: block; width: fit-content; margin-inline: auto;
  background: var(--seal); color: var(--parchment); font-weight: 900; letter-spacing: .12em; text-transform: uppercase;
  font-size: .95rem; padding: .7rem 1.4rem; border-radius: 999px;
  box-shadow: inset 0 0 0 2px rgba(247,217,176,.35), 0 0 0 3px var(--night), 0 0 0 5px var(--edge-hi), 0 10px 24px rgba(0,0,0,.45);
}

/* ---------- parchment sections ---------- */
.parchment { --bg: var(--parchment); background: var(--parchment); color: var(--ink); }
.parchment .kicker { color: var(--seal); }
.parchment a:hover { color: var(--seal); }
.listing { text-align: center; }
.listing p:last-child { color: var(--ink-soft); margin-bottom: 0; }

/* ---------- gloom to gold ---------- */
.gloom {
  --bg: var(--gloom);
  background: linear-gradient(180deg, var(--gloom) 0%, #2A2440 35%, #4A3524 75%, #6B4A26 100%);
  text-align: center;
}
.reveals { display: grid; gap: 2rem; margin-top: 2rem; }
.reveal { margin: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair a { position: relative; display: block; border-radius: 6px; overflow: hidden; border: 2px solid var(--edge); }
.pair img { width: 100%; aspect-ratio: 1440 / 1010; object-fit: cover; transition: transform .25s ease; }
.pair a:hover img, .pair a:focus-visible img { transform: scale(1.03); }
.tag {
  position: absolute; left: 10px; top: 10px; font-weight: 900; font-size: .75rem; letter-spacing: .12em;
  text-transform: uppercase; padding: .25rem .6rem; border-radius: 3px;
}
.tag.before { background: #2B3366; color: #DCE2FF; }
.tag.after { background: var(--gold); color: var(--ink); }
.reveal figcaption { margin-top: .6rem; font-family: var(--serif); font-weight: 600; color: var(--parchment); }
.wip {
  display: inline-block; margin: 2rem 0 0; font-size: .85rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--gold); border: 1px dashed var(--edge-hi); padding: .35rem .9rem; border-radius: 3px;
}

/* ---------- the job ---------- */
.job { --bg: var(--night); background: var(--night); }
.steps { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; counter-reset: step; }
.steps li {
  counter-increment: step; position: relative; background: var(--panel); border: 2px solid var(--edge); border-radius: 6px;
  padding: 1.3rem 1.2rem 1.1rem; box-shadow: inset 0 0 0 1px rgba(242,196,109,.12), 0 8px 18px rgba(0,0,0,.35);
}
.steps li::before {
  content: counter(step); display: grid; place-items: center; width: 2.1rem; height: 2.1rem; margin-bottom: .7rem;
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--seal-hi), var(--seal) 60%, #7A221A);
  color: var(--parchment); font-family: var(--serif); font-weight: 800; font-size: 1.05rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.steps p { font-size: 1rem; margin: 0; color: var(--muted-light); }

/* ---------- disclosure form ---------- */
.disclose { --bg: var(--parchment); }
.form {
  background: #FBF3DF; border: 1px solid var(--parchment-edge); border-radius: 4px; padding: clamp(1.4rem, 4vw, 2.6rem);
  box-shadow: 0 1px 0 #fff inset, 0 18px 36px rgba(36,23,15,.18); transform: rotate(-.6deg);
}
.checks { list-style: none; margin: 1.2rem 0 1.5rem; padding: 0; columns: 2; column-gap: 2rem; }
.checks li {
  break-inside: avoid; position: relative; padding: .45rem 0 .45rem 2.1rem; border-bottom: 1px dotted var(--parchment-edge);
  font-family: var(--serif); font-weight: 500;
}
.checks li::before {
  content: "\2713"; position: absolute; left: 0; top: .5rem; width: 1.35rem; height: 1.35rem; display: grid; place-items: center;
  border: 2px solid var(--ink); border-radius: 2px; font-family: var(--sans); font-weight: 900; font-size: .9rem; line-height: 1; color: var(--seal);
}
.signed { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.signed p { margin: 0; font-family: var(--serif); font-style: italic; color: var(--ink-soft); }
.wax {
  display: grid; place-items: center; width: 92px; height: 92px; border-radius: 50%; flex: none; transform: rotate(-12deg);
  background: radial-gradient(circle at 35% 30%, var(--seal-hi) 0%, var(--seal) 55%, #6E1E17 100%);
  color: #F7D9B0; font-family: var(--serif); font-weight: 900; font-size: 1.15rem; letter-spacing: .08em;
  box-shadow: inset 0 0 0 5px rgba(110,30,23,.55), inset 0 0 0 7px rgba(247,217,176,.35), 0 6px 14px rgba(36,23,15,.35);
}

/* ---------- gallery ---------- */
.photos { --bg: var(--panel); background: var(--panel); }
.sub { color: var(--muted-light); }
.gallery { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gallery li:first-child { grid-column: span 2; grid-row: span 2; }
.gallery a { display: block; border-radius: 6px; overflow: hidden; background: var(--night); aspect-ratio: 16 / 9; border: 2px solid var(--edge); }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.gallery a:hover img, .gallery a:focus-visible img { transform: scale(1.04); }

/* ---------- after the story: a deed ---------- */
.after { --bg: var(--night); background: var(--night); }
.deed {
  margin-top: 1.5rem; background: var(--parchment); color: var(--ink); border-radius: 6px; overflow: hidden;
  border: 2px solid var(--edge-hi); box-shadow: inset 0 0 0 6px var(--parchment), inset 0 0 0 7px var(--parchment-edge), 0 14px 30px rgba(0,0,0,.4);
  padding: 10px;
}
.deed dl { margin: 0; display: grid; grid-template-columns: minmax(9rem, 13rem) 1fr; }
.deed dt, .deed dd { margin: 0; padding: .9rem 1.1rem; border-bottom: 1px solid rgba(184,151,106,.45); }
.deed dt { font-family: var(--serif); font-weight: 800; font-size: 1.05rem; color: var(--seal); display: flex; align-items: center; }
.deed dl > :nth-last-child(-n+2) { border-bottom: 0; }

/* ---------- where it stands ---------- */
.stands { --bg: #2A1E15; background: linear-gradient(180deg, #2A1E15 0%, var(--panel) 100%); text-align: center; }
.todo { list-style: none; margin: 1.2rem auto 2rem; padding: 0; display: grid; gap: .5rem; max-width: 30rem; text-align: left; }
.todo li { position: relative; padding: .6rem .9rem .6rem 2.4rem; background: var(--panel-hi); border: 1px solid var(--edge); border-radius: 4px; color: var(--muted-light); }
.todo li::before {
  content: ""; position: absolute; left: .9rem; top: 50%; width: .8rem; height: .8rem; margin-top: -.4rem;
  border: 2px solid var(--gold); border-radius: 2px;
}

/* ---------- footer ---------- */
.foot { background: #0F0B08; color: var(--muted-light); padding-block: 3rem calc(3rem + env(safe-area-inset-bottom)); font-size: 1rem; border-top: 2px solid var(--edge); }
.foot a { color: var(--text-light); }
.studio { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.studio img { width: 64px; height: 64px; flex: none; }
.studio p { margin: 0; font-size: 1rem; }
.studio strong { font-family: var(--serif); font-size: 1.35rem; color: var(--text-light); }
.foot details { border-top: 1px solid #2E2219; padding: .8rem 0; }
.foot summary { cursor: pointer; font-weight: 800; color: var(--text-light); }
.foot details p { margin: .7rem 0 0; }
.fine { font-size: .875rem; color: #9A8B73; margin: 1rem 0 0; }

/* ---------- picture viewer ---------- */
dialog#viewer { border: 0; padding: 0; background: transparent; max-width: min(96vw, 1600px); max-height: 92vh; overflow: visible; }
dialog#viewer::backdrop { background: rgba(15,11,8,.92); }
dialog#viewer img { max-height: 88vh; width: auto; border-radius: 6px; border: 2px solid var(--edge); }
dialog#viewer .close {
  position: absolute; top: -18px; right: -12px; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--night); background: var(--gold); color: var(--ink); font-size: 1.8rem; line-height: 1; cursor: pointer; font-weight: 900;
}

/* ---------- smaller screens ---------- */
@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  .hero { min-height: 480px; }
  .pair { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .checks { columns: 1; }
  .form { transform: none; }
  .gallery { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gallery li:first-child { grid-column: span 2; grid-row: auto; }
  .deed dl { grid-template-columns: 1fr; }
  .deed dt { border-bottom: 0; padding-bottom: .1rem; }
  .deed dd { padding-top: .1rem; }
  .deed dl > :nth-last-child(2) { border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.page404 { --bg: var(--parchment); min-height: 100vh; display: grid; place-items: center; text-align: center; }
a.status { text-decoration: none; }
a.status:hover { color: #fff; }
