/* The schoolhouse noticeboard (schools.html only; award polish #26).
   The three lesson cards are Tom's three painted papers pinned to his painted
   cork board, with the live text set on them in navy ink.

   THE BOARD, from one approved painting (noticeboard2.png):
   - the wooden FRAME is a CSS border-image 9-slice cut just inside the
     painting's dark inner lip (68/66/76/64 source px): plain wood rails
     stretch, screws stay in the corners and scale with --nb-scale. The frame
     file has its interior flattened; without `fill` it is never drawn.
   - the CORK is the painting's interior as a lazy <img>, object-fit: cover,
     so the speckle stays isotropic however tall the board grows and the
     painted top-centre lamplight keeps its shape.
   - the pressed flower and the gold star are feathered crops of the same
     pixels, placed where the painting has them.

   THE PAPERS (2026-10-17, replacing CSS paper that Tom rejected: a flat cream
   rectangle next to a painting reads as a UI card pasted on top). Each note is
   one painted cutout with its pin painted in, applied as a border-image
   9-slice whose WIDTH is fixed per breakpoint (so the tear, pin, curl, lift
   and crease render at one uniform scale, never smeared) and whose HEIGHT is
   the painting's own unless the text needs more, in which case only the
   plain paper between the fixed slices stretches. --w is the display width;
   every slice is derived from it, so one rule serves all three papers:
     torn notebook page  640 x 859   slices 148 / 25 / 195 / 25 (pin + tear
                         in the top slice, the curl in the bottom one)
     small index card    640 x 510   slices 111 / 20 / 101 / 20 (lift bottom)
     folded letter       640 x 847   slices 456 / 24 /  24 / 24 (the whole
                         upper leaf incl. the crease is the top slice; the
                         prop sits on it, the text goes below the crease)
   Shadows are warm drop-shadows that follow the paper's silhouette, cast
   downward from the board's top-centre light. */

.noticeboard {
  --nb-scale: 0.5;
  --nb-pad-x: 1.6rem;
  --nb-pad-y: 1.9rem;
  position: relative;
  margin: 1.5rem 0 0.8rem;
  border-style: solid;
  border-width: calc(68px * var(--nb-scale)) calc(66px * var(--nb-scale)) calc(76px * var(--nb-scale)) calc(64px * var(--nb-scale));
  border-image: url("/Assets/schools/noticeboard-frame-w1672.webp") 68 66 76 64 / calc(68px * var(--nb-scale)) calc(66px * var(--nb-scale)) calc(76px * var(--nb-scale)) calc(64px * var(--nb-scale)) stretch;
  background: #c17a36;
  box-shadow:
    0 2px 6px rgba(6, 10, 38, 0.45),
    0 26px 60px -12px rgba(6, 10, 38, 0.75);
}
.noticeboard-cork {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  display: block;
  pointer-events: none;
}
.noticeboard::before, .noticeboard::after {
  content: "";
  position: absolute;
  z-index: 1;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
}
.noticeboard::before {
  top: calc(-16px * var(--nb-scale));
  left: calc(-16px * var(--nb-scale));
  width: calc(148px * var(--nb-scale));
  height: calc(148px * var(--nb-scale));
  background-image: url("/Assets/schools/noticeboard-flower-w148.webp");
}
.noticeboard::after {
  top: calc(-22px * var(--nb-scale));
  right: calc(-20px * var(--nb-scale));
  width: calc(116px * var(--nb-scale));
  height: calc(116px * var(--nb-scale));
  background-image: url("/Assets/schools/noticeboard-star-w116.webp");
}

/* The notes: a wrapping row, cork showing between and around them. */
.noticeboard .lesson-steps {
  position: relative;
  z-index: 2;
  list-style: none;
  margin: 0;
  padding: var(--nb-pad-y) var(--nb-pad-x) calc(var(--nb-pad-y) + 0.3rem);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  align-items: flex-start;
  gap: 1.6rem 1rem;
  box-shadow: inset 0 0 calc(44px * var(--nb-scale)) rgba(60, 24, 0, 0.42);
}

/* One painted paper. --w is set per note and per breakpoint. */
.noticeboard .lesson-step {
  --iw: 640;
  --tilt: 0deg;
  position: relative;
  flex: none;
  box-sizing: border-box;
  width: var(--w);
  min-height: calc(var(--w) * var(--ih) / var(--iw));
  border-style: solid;
  border-color: transparent;
  border-width: calc(var(--w) * var(--t) / var(--iw)) calc(var(--w) * var(--r) / var(--iw)) calc(var(--w) * var(--b) / var(--iw)) calc(var(--w) * var(--l) / var(--iw));
  border-image-source: var(--paper);
  border-image-slice: var(--t) var(--r) var(--b) var(--l) fill;
  border-image-repeat: round stretch;
  padding: 0.1rem var(--pad) 0.3rem;
  color: #1B2A6B;
  transform: rotate(var(--tilt));
  transform-origin: 50% 6%;
  filter: drop-shadow(0 9px 7px rgba(58, 27, 2, 0.36)) drop-shadow(0 2px 2px rgba(58, 27, 2, 0.28));
}
.noticeboard .note-torn {
  --paper: url("/Assets/schools/note-torn-w640.webp");
  --ih: 859; --t: 148; --r: 25; --b: 195; --l: 25;
  --w: 250px; --pad: 1rem; --tilt: -1.4deg;
}
.noticeboard .note-card {
  --paper: url("/Assets/schools/note-card-w640.webp");
  --ih: 510; --t: 111; --r: 20; --b: 101; --l: 20;
  --w: 304px; --pad: 1.1rem; --tilt: 1.1deg;
  margin-top: 1.4rem;
}
.noticeboard .note-letter {
  --paper: url("/Assets/schools/note-letter-w640.webp");
  --ih: 847; --t: 456; --r: 24; --b: 24; --l: 24;
  --w: 230px; --pad: 0.95rem; --tilt: -0.7deg;
  margin-top: 0.5rem;
}

/* The prop (book / notebook / lantern), printed on the paper. */
.noticeboard .lesson-step-img {
  display: block;
  width: auto;
  max-width: 100%;
  margin: 0 auto 0.55rem;
  object-fit: contain;
  height: 74px;
}
.noticeboard .note-card .lesson-step-img { height: 66px; }
/* The lantern stands on the upper leaf of the folded letter, above the
   crease (inside the top slice, so it is positioned, centred). */
.noticeboard .note-letter .lesson-step-img {
  position: absolute;
  left: 50%;
  /* measured from the padding box, which begins under the crease slice
     (456), so the offset is negative: the lantern's top at 132 of 847 */
  top: calc(var(--w) * (132 - 456) / var(--iw));
  height: calc(var(--w) * 282 / var(--iw));
  transform: translateX(-50%);
  margin: 0;
}
.noticeboard .note-letter { padding-top: 0.55rem; }

/* Ink. Measured on the papers' darkest text-area pixels: titles >= 8.7:1,
   body >= 7.8:1, the brown label >= 5.5:1. Nothing under 14px. */
.noticeboard .lesson-step-min {
  font-family: 'Fredoka', 'M PLUS Rounded 1c', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  color: #6E4512;
  line-height: 1.35;
  margin: 0;
}
.noticeboard .lesson-step-title {
  font-family: 'Fredoka', 'M PLUS Rounded 1c', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
  margin: 0.1rem 0 0.4rem;
  color: #1B2A6B;
}
.noticeboard .lesson-step p { font-size: 0.875rem; margin: 0; color: #2A3463; line-height: 1.6; }
.noticeboard .lesson-step p + p { margin-top: 0.5rem; }

/* Japanese on the papers breaks only between phrases: a <wbr> sits at every
   phrase boundary (BudouX + the hand-checked list in award-polish's
   scripts/jp-phrases.mjs, written here by hand) and keep-all removes every
   other opportunity. .jp-nobr holds a bracket to its word (WebKit would
   break after 「). Same class names and declarations as award-polish, so the
   two fold together. */
.noticeboard .lesson-step .jp-phrase { word-break: keep-all; overflow-wrap: anywhere; }
.noticeboard .lesson-step .jp-nobr { white-space: nowrap; }

/* Settle-in on reveal: each sheet fades up and swings from its pin to its
   resting tilt. Driven by the page's own .scroll-reveal/.revealed classes. */
.noticeboard .lesson-step.scroll-reveal {
  transition: opacity var(--duration-slowest) var(--ease-gentle),
              transform var(--duration-scene) var(--ease-out);
}
/* Hidden start gated on .js (the head script), like every other reveal:
   without JavaScript the papers are simply there. */
.js .noticeboard .lesson-step.scroll-reveal:not(.revealed) {
  opacity: 0;
  transform: translateY(8px) rotate(calc(var(--tilt) * 2.6));
}
.noticeboard .lesson-step.scroll-reveal.revealed {
  opacity: 1;
  transform: rotate(var(--tilt));
}
@media (prefers-reduced-motion: reduce) {
  .noticeboard .lesson-step.scroll-reveal, .js .noticeboard .lesson-step.scroll-reveal:not(.revealed), .noticeboard .lesson-step.scroll-reveal.revealed {
    opacity: 1;
    transform: rotate(var(--tilt));
    transition: none;
  }
}

/* Wide screens: the board sits a little wider than the text column. */
@media (min-width: 1100px) {
  .noticeboard { margin-inline: calc(-1 * min(56px, (100vw - 900px) / 2)); }
}
/* The 900-1099 column is 860px wide: the three papers scale down a notch. */
@media (max-width: 1099px) {
  .noticeboard { --nb-pad-x: 1.1rem; }
  .noticeboard .lesson-steps { gap: 1.6rem 0.75rem; }
  .noticeboard .note-torn { --w: 222px; --pad: 0.85rem; }
  .noticeboard .note-card { --w: 272px; --pad: 0.95rem; }
  .noticeboard .note-letter { --w: 210px; --pad: 0.8rem; }
}
/* iPad held upright: two papers across, the letter centred beneath. */
@media (max-width: 860px) {
  .noticeboard { --nb-scale: 0.44; --nb-pad-x: 1.3rem; --nb-pad-y: 1.6rem; }
  .noticeboard .lesson-steps { gap: 1.4rem 1.6rem; }
  .noticeboard .note-torn { --w: 252px; --pad: 1.05rem; }
  .noticeboard .note-card { --w: 318px; --pad: 1.15rem; }
  .noticeboard .note-letter { --w: 250px; --pad: 1.05rem; margin-top: 0; }
}
/* Phone: one column; each paper as wide as the board allows (never wider
   than 300px), the board grows tall, the frame scales down. */
@media (max-width: 600px) {
  .noticeboard { --nb-scale: 0.34; --nb-pad-x: 0.9rem; --nb-pad-y: 1.4rem; margin: 1.2rem 0 0.6rem; }
  .noticeboard .lesson-steps { gap: 1.5rem; }
  .noticeboard .lesson-step { --w: min(300px, 100vw - 2.5rem - 45px - 1.8rem); --pad: 1.1rem; }
  .noticeboard .note-card, .noticeboard .note-letter { margin-top: 0; }
  .noticeboard .lesson-step p, .noticeboard .lesson-step-min { font-size: 0.9rem; }
  .noticeboard .lesson-step-img { height: 80px; }
  .noticeboard .note-card .lesson-step-img { height: 70px; }
}
