/* The play page dressed as a 1943 Eighth Air Force bomb group. Light: the briefing room (manila paper, typed and
   stencilled, an olive drab header, rubber stamps). Dark: olive drab, the paint on the aeroplane itself.
   Only the play page (body.mission) uses it; the explorer and proof pages keep style.css's plain look. The colour
   roles are style.css's, redefined, so every panel follows; this file adds the type, the paper and the markings. */

body.mission {
  --page: #d8cdae; --surface: #f4edd9; --ink: #221f16; --ink-2: #4a4433; --muted: #7f7558;
  --grid: #dccfae; --axis: #ab9e78; --ring: rgba(60, 48, 20, 0.16); --series-1: #2b4d86;
  --od: #6d6c3e; --od-deep: #3e4220; --od-ink: #efe6c8; --stamp-red: #a3322a; --stamp-blue: #2b4d86;
  --usaaf-blue: #1f3b78; --paper-edge: #c7b88f; --button: #3e4220; --button-ink: #f1e8ca;
  --map-sea: #c9d8d3; --map-land: #ece2c6; --map-coast: #8c7b56;
  --type: "Special Elite", "Courier Prime", "Courier New", monospace;
  --stencil: "Stardos Stencil", "Arial Narrow", "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.mission {
    --page: #191a12; --surface: #26281b; --ink: #ece3c6; --ink-2: #c2b998; --muted: #8e8669;
    --grid: #383a28; --axis: #545639; --ring: rgba(236, 227, 198, 0.12); --series-1: #7397d6;
    --od: #5c5c38; --od-deep: #3a3e20; --od-ink: #ece3c6; --button: #727540; --button-ink: #fbf5e2; --stamp-red: #d65a4c; --stamp-blue: #7397d6;
    --paper-edge: #3c3e2a; --map-sea: #1d2a2a; --map-land: #34342a; --map-coast: #6c6448;
  }
}
:root[data-theme="dark"] body.mission {
  --page: #191a12; --surface: #26281b; --ink: #ece3c6; --ink-2: #c2b998; --muted: #8e8669;
  --grid: #383a28; --axis: #545639; --ring: rgba(236, 227, 198, 0.12); --series-1: #7397d6;
  --od: #5c5c38; --od-deep: #3a3e20; --od-ink: #ece3c6; --button: #727540; --button-ink: #fbf5e2; --stamp-red: #d65a4c; --stamp-blue: #7397d6;
  --paper-edge: #3c3e2a; --map-sea: #1d2a2a; --map-land: #34342a; --map-coast: #6c6448;
}
/* The page around the content column (and below a short page) is painted from <html>, so it takes the theme too. */
html:has(body.mission) { background: #d8cdae; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):has(body.mission) { background: #191a12; } }
:root[data-theme="dark"]:has(body.mission) { background: #191a12; }
body.mission { min-height: 100vh; }
/* The theme's chart colours, over play.css's (whose dark-mode rule is more specific than a plain class). */
:root body.mission .map-card { --map-sea: inherit; --map-land: inherit; --map-coast: inherit; }

/* The desk under the papers: a faint weave, so the page isn't flat. */
body.mission {
  background-color: var(--page);
  background-image: repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.018) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 6px);
}

/* ---- type ---- */
body.mission h1, body.mission h2, body.mission .hero-title, body.mission .tally-box .n {
  font-family: var(--stencil); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
}
body.mission h2 { font-size: 16px; letter-spacing: 0.06em; }
body.mission h3.panel, body.mission .kicker, body.mission .status-table th, body.mission .log .tbl,
body.mission .log .rl, body.mission .prompt .why, body.mission .chip, body.mission .briefing,
body.mission .sub, body.mission .field, body.mission .crew-role, body.mission .ring-label, body.mission .clock {
  font-family: var(--type);
}
body.mission .chip { letter-spacing: 0.02em; padding-top: 3px; } /* Special Elite sits high: nudge it to the middle */
.mission .kicker { margin: 0 0 1px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }

/* ---- the header: an olive drab panel with the national insignia ---- */
body.mission .page-head {
  align-items: center; background: var(--od-deep); color: var(--od-ink); border-radius: 8px;
  padding: 8px 14px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 0 rgba(0, 0, 0, 0.15);
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 120px 100%; /* panel seams */
}
.mission .head-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mission .page-head h1 { color: var(--od-ink); font-size: 21px; margin: 0; }
.mission .page-head .sub, .mission .page-head .kicker { color: color-mix(in srgb, var(--od-ink) 70%, transparent); }
.mission .page-head .ghost, .mission .page-head a.ghost { color: var(--od-ink); border-color: color-mix(in srgb, var(--od-ink) 35%, transparent); font-family: var(--type); }
.mission .page-head .ghost:hover { background: rgba(255, 255, 255, 0.08); }
.mission .insignia { width: 72px; height: 26px; flex: none; }
.mission .ins-bar { fill: #fff; stroke: var(--usaaf-blue); stroke-width: 2.5; }
.mission .ins-disc { fill: var(--usaaf-blue); }
.mission .ins-star { fill: #fff; }
/* The same mark painted on the wing, scaled with the drawing. */
.mission .insignia-mark .ins-bar { stroke-width: 0.35; }

/* ---- paper: cards are sheets, with a heading rule like a typed form ---- */
body.mission .card, body.mission .tally-box {
  background: var(--surface); border: 1px solid var(--paper-edge); border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 2px 6px rgba(40, 30, 10, 0.08);
}
body.mission .card > h2, body.mission .card-head h2, body.mission .card > div > .card-head h2 { border-bottom: 2px solid var(--ink); padding-bottom: 2px; display: inline-block; }
body.mission .status-table th { text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; font-weight: 400; border-bottom-color: var(--ink-2); }
body.mission h3.panel { font-weight: 400; letter-spacing: 0.1em; }

/* ---- controls ---- */
body.mission .primary {
  background: var(--button); color: var(--button-ink); font-family: var(--stencil); font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; border-radius: 3px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
body.mission .ghost { border-radius: 3px; }
body.mission select, body.mission input[type="text"] { border-radius: 3px; font-family: var(--type); }

/* Dice: ivory, with black pips; the tens die is red, like the rulebook's coloured die. */
body.mission .die { background: #f7f1e0; border: 1.5px solid #3b3626; border-radius: 7px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12); }
body.mission .die .pip { background: #1b1912; }
body.mission .die.tens { background: #9e2b22; border-color: #5e1712; }
body.mission .die.tens .pip { background: #f7f1e0; }

/* ---- the result, stamped on the report ---- */
body.mission .banner { background: transparent; border-left: 0; padding: 4px 0 8px; }
body.mission .banner h2 {
  display: inline-block; border: 3px double var(--stamp-blue); color: var(--stamp-blue); padding: 3px 10px 1px;
  transform: rotate(-2deg); transform-origin: left center; border-radius: 3px; margin-bottom: 8px; opacity: 0.92;
}
body.mission .banner.bad h2 { border-color: var(--stamp-red); color: var(--stamp-red); }

/* ---- the start screen ---- */
.mission .hero {
  display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: center; margin-bottom: 16px;
  background: var(--od-deep); color: var(--od-ink); border-radius: 6px; padding: 14px 22px; overflow: hidden;
  background-image: linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px), linear-gradient(rgba(0, 0, 0, 0.12) 1px, transparent 1px);
  background-size: 90px 100%, 100% 46px;
}
.mission .hero-plane { width: 200px; height: 150px; }
.mission .hero-plane .airframe { fill: var(--od); stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.3; }
.mission .hero-plane .art { fill: none; stroke: rgba(0, 0, 0, 0.55); vector-effect: non-scaling-stroke; stroke-width: 0.6px; }
.mission .hero-plane .art.fine { opacity: 0.4; }
.mission .hero-title { font-size: 40px; margin: 0; color: var(--od-ink); line-height: 1; }
.mission .hero-sub { margin: 6px 0 0; font-family: var(--type); color: color-mix(in srgb, var(--od-ink) 80%, transparent); }
.mission .hero .kicker { color: #e2c46b; }
@media (max-width: 600px) { .mission .hero { grid-template-columns: 1fr; } .mission .hero-title { font-size: 30px; } }

/* ---- the plane view: an olive drab Fortress over the ring chart ---- */
body.mission .plane-card .b17 .airframe { fill: var(--od); }
body.mission .plane-card .b17 .art.lines { stroke: rgba(20, 18, 8, 0.75); }
body.mission .plane-card .b17 .art.details { stroke: rgba(20, 18, 8, 0.6); }
body.mission .plane-card .b17 .art.fine { stroke: rgba(20, 18, 8, 0.5); opacity: 0.45; }
body.mission .plane-card .engine-label { fill: var(--od-ink); }
body.mission .plane-card .fighter .balkenkreuz { fill: #111; stroke: #fff; stroke-width: 0.9; paint-order: stroke; }
body.mission .plane-card .fighter.destroyed .balkenkreuz { opacity: 0.5; }
body.mission .plane-card .ring { stroke: var(--axis); stroke-dasharray: 1 3; }
body.mission .map .map-b17-name { font-family: var(--type); }

/* ---- the campaign: bombs painted under the cockpit, one per mission ---- */
body.mission .tour { grid-template-columns: repeat(25, 12px); gap: 5px; }
/* This overrides play.css's own narrow-screen rule for .tour (lower specificity, so it would otherwise lose to
   the unconditional rule above regardless of width) — same breakpoint, this theme's column count. */
@media (max-width: 700px) { body.mission .tour { grid-template-columns: repeat(13, 12px); } }
body.mission .tour .pip {
  width: 12px; height: 26px; border: 0; border-radius: 0; background: var(--grid);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 28'%3E%3Cpath d='M6 27C2.4 23.6 1.6 17 2.6 10.5L3.2 7 1 3V0h10v3L8.8 7l.6 3.5C10.4 17 9.6 23.6 6 27z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 28'%3E%3Cpath d='M6 27C2.4 23.6 1.6 17 2.6 10.5L3.2 7 1 3V0h10v3L8.8 7l.6 3.5C10.4 17 9.6 23.6 6 27z'/%3E%3C/svg%3E") center / contain no-repeat;
}
body.mission .tour .pip.good { background: var(--stamp-blue); }
body.mission .tour .pip.bad { background: var(--stamp-red); }
body.mission .tour .pip.draw { background: var(--muted); }
body.mission .tally-box .n { font-size: 30px; }
body.mission .chip.ace { border-color: #b8860b; color: var(--ink); background: color-mix(in srgb, #e2c46b 30%, transparent); }

/* ---- the log: a typed record ---- */
body.mission .log { font-family: var(--type); font-size: 12px; }
body.mission .log li.new { background: color-mix(in srgb, #e2c46b 22%, transparent); box-shadow: inset 3px 0 0 var(--od); }

@media print {
  /* Black ink on white paper. The theme's paper, olive and stamp colours are set on body.mission (and again for
     dark mode), which outranks play.css's print colours on :root, so they're replaced here, !important to beat the
     dark-mode rules: printing from a dark screen gives the same page. */
  body.mission {
    --page: #fff !important; --surface: #fff !important; --ink: #000 !important; --ink-2: #333 !important; --muted: #666 !important;
    --grid: #d4d4d4 !important; --axis: #9a9a9a !important; --ring: rgba(0, 0, 0, 0.12) !important; --series-1: #555 !important;
    --od: #555 !important; --od-deep: #000 !important; --od-ink: #000 !important; --stamp-red: #000 !important; --stamp-blue: #000 !important;
    --usaaf-blue: #000 !important; --paper-edge: #bbb !important; --button: #000 !important; --button-ink: #fff !important;
    --map-sea: #fff !important; --map-land: #f2f2f2 !important; --map-coast: #808080 !important;
  }
  html:has(body.mission), body.mission { background: #fff !important; }
  body.mission .page-head { background: none; color: #000; box-shadow: none; padding: 0; }
  .mission .page-head h1 { color: #000; }
  .mission .page-head .sub, .mission .page-head .kicker { color: #444; }
  body.mission .card, body.mission .tally-box, body.mission .banner, body.mission .log li { background: none !important; box-shadow: none !important; }
  /* Chips as plain outlines: grey for the routine, black for the bad news. */
  body.mission .chip { background: none !important; color: #000 !important; border-color: #9a9a9a !important; }
  body.mission .chip.bad, body.mission .chip.ace { border-color: #000 !important; }
  /* The map and the B-17 in black ink only: their marks (hits, fires, the route) keep their shapes, in greys. */
  body.mission .map-card svg, body.mission .plane-card svg { filter: grayscale(1); }
  /* A pale B-17, so its outline drawing and the hit markers carry it rather than a solid silhouette. */
  body.mission .plane-card .b17 .airframe { fill: #ececec; }
}

/* ---- the site's navigation, in the mission dress ---- */
body.mission .site-nav { border-bottom: 2px solid var(--od-deep); margin: -6px 0 10px; padding: 2px 0 6px; flex: none; }
body.mission .site-nav .brand { font-family: var(--stencil); letter-spacing: 0.05em; text-transform: uppercase; }
body.mission .site-nav .brand-sub { font-family: var(--type); text-transform: none; letter-spacing: 0; }
body.mission .site-nav ul a { font-family: var(--type); color: var(--ink-2); border-radius: 3px; }
body.mission .site-nav ul a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -3px 0 var(--od); border-radius: 3px 3px 0 0; }
body.mission .site-nav .theme-switch { font-family: var(--type); }
/* The game screen fits the window: the nav is a slim strip above the mission's header. */
body:has(#game:not([hidden])) .site-nav { margin: -4px 0 6px; padding-bottom: 4px; }

/* ---- the home page ---- */
body.home, body.guide { max-width: 1040px; }
.home .hero { grid-template-columns: 230px 1fr; padding: 22px 28px; margin-bottom: 22px; }
.home .hero-plane { width: 230px; height: 180px; }
.home .hero-title { font-size: 52px; }
.mission .section-title { font-size: 15px; letter-spacing: 0.12em; margin: 0 0 10px; color: var(--ink-2); border-bottom: 1px solid var(--paper-edge); padding-bottom: 4px; }
.orders { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 26px; }
.order {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--paper-edge); border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 2px 6px rgba(40, 30, 10, 0.08); transition: transform 120ms ease, box-shadow 120ms ease;
}
.order:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(40, 30, 10, 0.16); }
.order:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }
.order-kicker { font-family: var(--type); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.order-title { font-family: var(--stencil); font-weight: 700; font-size: 24px; letter-spacing: 0.05em; text-transform: uppercase; }
.order-text { font-family: var(--type); font-size: 13px; color: var(--ink-2); }
.primary-order { background: var(--button); border-color: var(--button); }
.primary-order .order-title, .primary-order .order-text { color: var(--button-ink); }
.primary-order .order-kicker { color: #e2c46b; }
.site-foot { font-family: var(--type); font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--paper-edge); padding-top: 10px; }
.site-foot p { margin: 0 0 4px; }
@media (max-width: 640px) { .home .hero { grid-template-columns: 1fr; } .home .hero-title { font-size: 36px; } }

/* ---- how to play ---- */
.guide-head { margin-bottom: 16px; }
.guide-head h1 { font-size: 34px; margin: 0 0 6px; }
.guide-head .sub { max-width: 70ch; font-family: var(--type); }
.guide-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 20px; align-items: start; }
.guide-toc { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; font-family: var(--type); font-size: 13px; }
.guide-toc a { color: var(--ink-2); text-decoration: none; padding: 4px 8px; border-left: 2px solid var(--paper-edge); }
.guide-toc a:hover { color: var(--ink); border-left-color: var(--od); background: var(--ring); }
.guide-body .card { scroll-margin-top: 12px; }
.guide-body p, .guide-body li, .guide-body dd { line-height: 1.55; max-width: 75ch; }
.steps { padding-left: 22px; margin: 6px 0 0; }
.steps li { margin-bottom: 8px; }
.steps li::marker { font-family: var(--stencil); font-weight: 700; }
.plain { padding-left: 18px; margin: 6px 0 0; }
.plain li { margin-bottom: 6px; }
.parts, .terms { margin: 6px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.parts dt, .terms dt { font-family: var(--stencil); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 13px; padding-top: 2px; }
.parts dd, .terms dd { margin: 0; }
.mission kbd { font-family: var(--type); font-size: 12px; border: 1px solid var(--axis); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; background: var(--surface); }
@media (max-width: 760px) { .guide-layout { grid-template-columns: 1fr; } .guide-toc { position: static; flex-direction: row; flex-wrap: wrap; } .parts, .terms { grid-template-columns: 1fr; } }
/* On the game screen every pixel of height counts: the header drops its kicker (the nav carries the name). */
body:has(#game:not([hidden])) .page-head .kicker { display: none; }
