/*
 * base.css - colours, fonts, the 16:9 stage and the placeholder look.
 *
 * Talks to: every other stylesheet uses the variables defined here.
 *
 * Say it to a judge: "All our colours are named once here, and the whole kitchen sits
 * on a fixed 16:9 stage that shrinks or grows to fit the screen, so the layout is the
 * same on an iPad and a laptop."
 */

/* ---------- Fonts (local copies in /fonts, no Google request at runtime) ---------- */
@font-face {
  font-family: 'Homemade Apple';
  src: url('../fonts/homemade-apple-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Caveat';
  font-weight: 400;
  src: url('../fonts/caveat-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Caveat';
  font-weight: 700;
  src: url('../fonts/caveat-latin-700-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Reenie Beanie';
  src: url('../fonts/reenie-beanie-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Special Elite';
  src: url('../fonts/special-elite-latin-400-normal.woff2') format('woff2');
  font-display: swap;
}

:root {
  /* ---------- Palette: nothing is pure white or pure black ---------- */
  --harvest-gold: #d9a441;
  --avocado: #7c8b3f;
  --burnt-orange: #c2622d;
  --walnut: #5c3b22;
  --walnut-dark: #3b2616;
  --cream: #f3e8cf;
  --paper: #faf3e0;        /* the lightest colour we use */
  --gingham-red: #b5524a;
  --ink: #33261a;          /* the darkest text colour */
  --pencil: #6f6a63;
  --night: #17110d;        /* the darkest colour we use */
  --lamp-glow: #ffcf7a;
  --placeholder: #8f887c;
  --placeholder-edge: #6b655c;

  /* ---------- Fonts ---------- */
  --font-hand: 'Caveat', 'Segoe Print', cursive;
  --font-script: 'Homemade Apple', cursive;
  --font-scrawl: 'Reenie Beanie', cursive;
  --font-typed: 'Special Elite', 'Courier New', monospace;

  /* ---------- Stage unit ----------
     WHY: --u is 1% of the stage's width. The stage is the biggest 16:9 box that fits
     the screen, so sizing text and borders in --u makes them scale with the scene. */
  --stage-w: min(100vw, calc(100vh * 16 / 9));
  --u: calc(var(--stage-w) / 100);
}

/* WHY: on iPad Safari 100vh includes the area under the address bar. 100dvh is the
   part you can actually see. Older browsers skip this block and keep the vh version. */
@supports (height: 100dvh) {
  :root { --stage-w: min(100vw, calc(100dvh * 16 / 9)); }
}

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

html, body {
  /* WHY fixed: on an iPad a normal page can be dragged and "rubber-bands" at the
     edges. Pinning it in place stops the kitchen sliding about under a finger. */
  position: fixed;
  inset: 0;
  margin: 0;
  overflow: hidden;              /* the stage never scrolls */
  overscroll-behavior: none;
  touch-action: manipulation;    /* no double-tap zoom anywhere on the page */
  background: var(--night);      /* the letterbox bars */
  color: var(--cream);
  font-family: var(--font-hand);
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  /* WHY: stops iPad Safari's double-tap-to-zoom and the grey tap flash on our objects. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* A visible, warm focus outline for keyboard users. */
:focus-visible {
  outline: calc(var(--u) * 0.3) solid var(--lamp-glow);
  outline-offset: calc(var(--u) * 0.3);
  border-radius: calc(var(--u) * 0.5);
}

[hidden] { display: none !important; }

/* ---------- The stage and its three scenes ---------- */
.stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--stage-w);
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
  overflow: hidden;
  background: var(--walnut-dark);
  font-size: calc(var(--u) * 1.6);
  /* WHY: a long press on an iPad would otherwise select pictures and pop up
     "Copy / Save Image" over the kitchen. Text you type, and the writing on a card
     you're holding, can still be selected (see the rule below). */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input,
textarea,
.focus-holder .card-face {
  -webkit-user-select: text;
  user-select: text;
}

.scene,
.panels {
  position: absolute;
  inset: 0;
}

.panels { pointer-events: none; }        /* empty until a panel opens */
/* WHY: the lamp has a z-index so it shows above the darkness; panels must beat it. */
.panels { z-index: 10; }
.panels > * { pointer-events: auto; }

/* ---------- The title sign (shown while the lamp is off) ---------- */
/* Placed by percentages of the stage, clear of the lamp, its tag and the first note.
   WHY pointer-events: none: the sign only hangs there. It must never catch a click. */
.title-sign {
  position: absolute;
  left: 27%;
  top: 5.5%;
  width: 50%;
  aspect-ratio: 960 / 318;       /* the picture's shape, so the words fit before it loads */
  z-index: 3;                    /* above the dark kitchen, below the first-visit notes */
  pointer-events: none;
  filter: drop-shadow(0 calc(var(--u) * 0.5) calc(var(--u) * 1.1) rgba(0, 0, 0, 0.6));
  transition: opacity 1s ease;   /* coming back when the lamp goes off */
}
/* Lamp on: the sign fades away as the room lights up. It stays in the page at zero
   opacity, so screen readers can still find the heading. */
.title-sign.is-away {
  opacity: 0;
  transition: opacity 1.5s ease;
}
.title-sign img {
  display: block;
  width: 100%;
  height: 100%;
}
/* The words sit in the blank middle of the sign: under the rolling pin, above the
   heart, between the two sprigs of flowers. */
.title-sign-words {
  position: absolute;
  left: 17%;
  right: 17%;
  top: 19%;
  bottom: 30%;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--walnut-dark);
  /* WHY Caveat and not the thin script font: at this size, across a room on a
     projector, the script was hard to read. Caveat Bold is the site's own handwriting. */
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: calc(var(--u) * 4.5);
  line-height: 0.92;
  text-align: center;
}

/* ---------- Assets and their placeholders ---------- */
.asset {
  position: relative;
  width: 100%;
}

.asset img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.asset-bg img { object-fit: cover; }

/* Images kept on a white background: multiply makes the white disappear into
   whatever is underneath (see IMAGE-PROMPTS.txt, "ON WHITE"). */
.asset-onwhite { mix-blend-mode: multiply; }

.asset.is-placeholder {
  display: grid;
  place-items: center;
  background: var(--placeholder);
  border: calc(var(--u) * 0.15) dashed var(--placeholder-edge);
  border-radius: calc(var(--u) * 0.6);
  mix-blend-mode: normal;
  overflow: hidden;
}

.asset-bg.is-placeholder {
  border-radius: 0;
  background: #7a7368;
}

.asset-label {
  padding: 0 0.3em;
  font-family: var(--font-typed);
  font-size: calc(var(--u) * 0.85);
  line-height: 1.1;
  color: var(--ink);
  text-align: center;
  overflow-wrap: anywhere;
}

/* ---------- Cursor: a wooden classroom pointer ----------
   The picture is a tiny SVG written straight into the CSS (no extra file to load).
   "3 3" is the hot spot: the red rubber tip is the part that clicks.
   WHY: buttons need the rule too, or the browser swaps back to its own arrow. */
html,
button,
label,
input {
  cursor: url("data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2232%22 height=%2232%22 viewBox=%220 0 32 32%22%3E%3Cline x1=%224%22 y1=%224%22 x2=%2228%22 y2=%2228%22 stroke=%22%233b2616%22 stroke-width=%225%22 stroke-linecap=%22round%22/%3E%3Cline x1=%224%22 y1=%224%22 x2=%2228%22 y2=%2228%22 stroke=%22%23b9823f%22 stroke-width=%223%22 stroke-linecap=%22round%22/%3E%3Cline x1=%224%22 y1=%224%22 x2=%227%22 y2=%227%22 stroke=%22%23b5524a%22 stroke-width=%223.4%22 stroke-linecap=%22round%22/%3E%3Ccircle cx=%2227.5%22 cy=%2227.5%22 r=%222.4%22 fill=%22%23d9a441%22 stroke=%22%233b2616%22 stroke-width=%221%22/%3E%3C/svg%3E") 3 3, auto;
}

/* ---------- Reduced motion ----------
   motion.js puts the class "reduce-motion" on <body> when the device or the almanac
   asks for less movement. JavaScript animations check motion.js themselves; this
   rule stops the ones written in CSS (pendulum, lamp chain). Fades are still allowed. */
.reduce-motion .swings {
  animation: none !important;
}
