/* ============================================================
   HALL PASS — stylesheet
   Visual idea: a school hall pass. Institutional paper stock,
   ballpoint ink, rubber stamps, perforated edges.
   ============================================================ */

:root {
  --paper:      #E8E4D6;  /* exam-paper stock, the page itself      */
  --card:       #F2EFE4;  /* the pass slip, lighter than the page   */
  --ink:        #1B3A4B;  /* ballpoint navy — all body text         */
  --ink-soft:   #6B7C86;  /* faded ink for meta / captions          */
  --stamp:      #C2410C;  /* rubber-stamp orange — the one accent   */
  --rule:       #C4BFAC;  /* pencil rule lines & borders            */
  --board:      #23342B;  /* chalkboard green — header & footer     */

  --pass-w: 100%;
  --radius: 3px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  /* faint ruled-paper texture */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    rgba(27, 58, 75, 0.045) 31px,
    rgba(27, 58, 75, 0.045) 32px
  );
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- header : styled like the top of a paper form ---------- */

.masthead {
  background: var(--board);
  color: var(--card);
  border-bottom: 4px double rgba(242, 239, 228, 0.35);
}

.masthead .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.logo {
  font-family: "Bricolage Grotesque", "Archivo", sans-serif;
  font-weight: 800;
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
  color: var(--card);
  text-decoration: none;
  display: inline-block;
}

.logo span { color: var(--stamp); }

.masthead-meta {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(242, 239, 228, 0.62);
}

/* ---------- bookmark nudge ---------- */

/* A notice on the pass rather than fine print: paper stock, a rule
   border, and a stamp-orange bar down the edge. */
.bookmark-tip {
  margin: 24px 0 0;
  padding: 14px 18px;
  background: var(--card);
  border: 1.5px solid var(--rule);
  border-left: 5px solid var(--stamp);
  border-radius: var(--radius);
}

.bookmark-tip[hidden] { display: none; }

.bookmark-eyebrow {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--stamp);
  margin: 0 0 5px;
}

.bookmark-line {
  font-family: "Archivo", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink);
  margin: 0;
}

.bookmark-line kbd {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.82em;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--rule);
  border-bottom-width: 3px;
  border-radius: 4px;
  padding: 2px 7px;
  margin: 0 2px;
}

/* ---------- toolbar : filter chips + search ---------- */

.toolbar {
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  gap: 12px 16px;
  padding: 26px 0 22px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.search {
  flex: 0 0 210px;
  margin-left: auto;
}

.search input {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  width: 210px;
  padding: 7px 14px;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder {
  color: var(--ink-soft);
  text-transform: uppercase;
  opacity: 1;
}

.search input:hover { border-color: var(--ink); }

.search input:focus {
  outline: none;
  border-color: var(--stamp);
}

.search input:focus-visible {
  outline: 2px solid var(--stamp);
  outline-offset: 2px;
}

/* visually hidden, still read by screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}


.chip {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 13px;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip:hover { border-color: var(--ink); color: var(--ink); }

.chip[aria-pressed="true"] {
  background: var(--stamp);
  border-color: var(--stamp);
  color: #FFF6EF;
}

.chip:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- recently played : one scrolling row ---------- */

.recent {
  padding-bottom: 26px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--rule);
}

.recent[hidden] { display: none; }

.recent-head {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--stamp);
  margin: 0 0 14px;
}

.recent-strip {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.recent-strip .pass {
  flex: 0 0 200px;
  scroll-snap-align: start;
}

/* ---------- grid of passes ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 20px;
  padding-bottom: 64px;
}

.pass {
  /* Only cards near the viewport are laid out and painted. The
     intrinsic height is the real card height at each breakpoint, so
     the estimate a card is skipped with matches what it becomes.
     "auto" means the real size is remembered after first render. */
  content-visibility: auto;
  contain-intrinsic-size: auto 268px;
  position: relative;
  display: block;
  background: var(--card);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s;
}

.pass:hover,
.pass:focus-visible {
  transform: translateY(-3px);
  border-color: var(--ink);
  box-shadow: 4px 5px 0 rgba(27, 58, 75, 0.16);
}

.pass:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }

.pass[hidden] { display: none; }

.pass-thumb {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--rule);
  border-bottom: 1.5px dashed var(--rule); /* perforation */
}

.pass-body { padding: 12px 13px 14px; }

.pass-no {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.pass-no span { white-space: nowrap; }

.pass-cat { color: var(--stamp); }

.pass-name {
  font-family: "Bricolage Grotesque", "Archivo", sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}

.empty {
  grid-column: 1 / -1;
  padding: 48px 0;
  text-align: center;
  color: var(--ink-soft);
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.85rem;
}

/* ---------- game page ---------- */

.player-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 26px 0 16px;
}

.player-head h1 {
  font-family: "Bricolage Grotesque", "Archivo", sans-serif;
  font-weight: 800;
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 6px 0 0;
}

.back {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1.5px solid var(--stamp);
  padding-bottom: 2px;
}

.back:hover { color: var(--stamp); }

.stage {
  position: relative;
  background: var(--board);
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
}

.stage.tall {
  aspect-ratio: 3 / 4;
  max-width: 560px;
  margin: 0 auto;
}

/* the class is set from fullscreenchange in game.html */
.stage.is-fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

/* Fallback for browsers with no Fullscreen API on ordinary elements
   (iOS Safari). dvh keeps it correct as the address bar collapses;
   the vh line is the floor for browsers without dvh. */
.stage.is-expanded {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  aspect-ratio: auto;
  border: 0;
  border-radius: 0;
}

body.stage-open { overflow: hidden; }

/* the only way out once the page itself is hidden */
/* Top-centre: the ad network puts its skip control bottom-right, and
   games put HUD in the corners. The strip above the game is usually
   letterbox. Esc already works, so this only has to be findable. */
.stage-overlay {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: none;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  opacity: 0.28;
  transition: opacity 0.15s;
}

.stage.is-fullscreen .stage-overlay,
.stage.is-expanded .stage-overlay { display: flex; }

.stage-overlay:hover,
.stage-overlay:focus-within { opacity: 1; }

.stage-exit {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.54rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: #FFF6EF;
  background: rgba(27, 58, 75, 0.6);
  border: 1px solid rgba(242, 239, 228, 0.3);
  border-radius: 999px;
  padding: 4px 9px;
  cursor: pointer;
  transition: background 0.15s;
}

.stage-exit:hover { background: var(--stamp); }

.stage-exit:focus-visible {
  outline: 2px solid #FFF6EF;
  outline-offset: 2px;
}

@media (hover: none) and (pointer: coarse) {
  .stage-hint { display: none; }
}

.stage-hint {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.5rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(242, 239, 228, 0.8);
  background: rgba(27, 58, 75, 0.6);
  border-radius: 999px;
  padding: 4px 7px;
  pointer-events: none;
  white-space: nowrap;
}

.stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.fullscreen-btn {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--stamp);
  color: #FFF6EF;
  border: 0;
  border-radius: 999px;
  padding: 9px 17px;
  cursor: pointer;
}

.fullscreen-btn:hover { background: #9A330A; }

.more-head {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--stamp);
  border-top: 1px solid var(--rule);
  padding-top: 22px;
  margin: 44px 0 18px;
}

/* ---------- footer ---------- */

.foot {
  background: var(--board);
  color: rgba(242, 239, 228, 0.6);
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  margin-top: 30px;
}

.foot .wrap {
  padding-top: 26px;
  padding-bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.foot-legal {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 26px;
}

.foot-note {
  max-width: 74ch;
  margin: 0;
  letter-spacing: 0.04em;
  line-height: 1.6;
  color: rgba(242, 239, 228, 0.42);
}

/* ---------- accessibility ---------- */

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 620px) {
  .toolbar { flex-wrap: wrap; }
  .search { flex: 1 1 100%; margin-left: 0; order: -1; }
  .search input { width: 100%; }
}

@media (max-width: 1023px) {
  .pass { contain-intrinsic-size: auto 239px; }
}

@media (max-width: 560px) {
  .pass { contain-intrinsic-size: auto 211px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 13px; }
  .toolbar { padding: 14px 0 16px; }
  .bookmark-tip { margin-top: 16px; padding: 12px 14px; }
  .bookmark-line { font-size: 0.92rem; }
  .recent-strip { gap: 13px; }
  .recent-strip .pass { flex: 0 0 165px; }
}
