/* ════════════════════════════════════════════════════════════════════════
   ADVENT CALENDAR (page-advent.php, inc/advent.php, js/advent.js)
   24 plain pink doors on a board. A door swings open on its left hinge
   and fades, then it's gone for good and the prize sits in its hole.
   ════════════════════════════════════════════════════════════════════════ */

.tomo-advent-page {
  --door:       #FF4B9F;
  --door-back:  #ffc6df;
}
.tomo-advent-page .tomo-page-intro {
  max-width: 640px; margin: -18px auto 32px; text-align: center;
  font-family: 'Nunito', sans-serif; color: var(--muted); line-height: 1.6;
}

/* Computers: less empty space above and (mostly) below the doors, so the
   whole calendar and the footer line fit on one screen. */
@media (min-width: 861px) {
  .tomo-shop-wrap.tomo-advent-page { padding-top: 16px; padding-bottom: 20px; }
  .tomo-advent-page .tomo-page-head { padding: 4px 24px 22px; }
  .tomo-advent-page .tomo-advent { margin-bottom: 0; }
}

/* The title, in the mini games' pixel font: whole screen pixels per font
   pixel (--tp; 8px grid: 32px = 4px pixels, 24px = 3px on phones, two
   lines). The tomos' dark blue, a white edge one font pixel thick all
   round, then a hard shadow of the whole thing one font pixel down and
   right. Literal colours: the same in Pink Night. */
.tomo-advent-page .tomo-advent-title {
  --tp: 4px;
  font-family: 'Press Start 2P', monospace; font-weight: 400;
  font-size: calc(var(--tp) * 8); line-height: calc(var(--tp) * 10); letter-spacing: 0;
  -webkit-font-smoothing: none; font-smooth: never;
  color: #130036 !important;
  text-shadow:
    var(--tp) 0 #fff, calc(var(--tp) * -1) 0 #fff, 0 var(--tp) #fff, 0 calc(var(--tp) * -1) #fff,
    var(--tp) var(--tp) #fff, calc(var(--tp) * -1) var(--tp) #fff,
    var(--tp) calc(var(--tp) * -1) #fff, calc(var(--tp) * -1) calc(var(--tp) * -1) #fff;
  filter: drop-shadow(var(--tp) var(--tp) 0 rgba(19, 0, 54, 0.3));
}
@media (max-width: 600px) {
  .tomo-advent-page .tomo-advent-title { --tp: 3px; }
}

/* ── Test bar (shop managers, while it's not live) ─────────────────── */
.tomo-advent-testbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  max-width: 900px; margin: 0 auto 24px; padding: 10px 14px;
  border: 2px dashed var(--door); border-radius: 16px;
  font-family: 'Fredoka', sans-serif; font-size: 0.85rem; color: var(--ink);
}
.tomo-advent-testbar strong { color: var(--tomo-pink-text); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; }
.tomo-advent-testbar-note { color: var(--muted); flex-basis: 100%; order: 9; font-size: 0.78rem; }
.tomo-advent-testbar label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.tomo-advent-testbar select {
  font-family: 'Fredoka', sans-serif; font-size: 0.85rem; padding: 4px 8px;
  border: 2px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--ink);
}
.tomo-advent-testbar a { color: var(--ink); font-weight: 600; }

/* ── The doors, straight on the page ───────────────────────────────── */
/* 838px = six 128px doors + five 14px gaps: a 64px door picture is exactly
   2× there. Other widths: js/advent.js (snapDoors) trims the grid so the
   doors are a whole multiple of the picture in screen pixels. */
.tomo-advent { position: relative; max-width: 838px; margin: 0 auto 40px; }
.tomo-advent-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px;
}
/* Tablets: 4 across. Phones: 3 across, so the calendar runs down the
   page (8 rows) with doors big enough to tap. */
@media (max-width: 860px) { .tomo-advent-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
@media (max-width: 560px) { .tomo-advent-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; } }

/* A hole in the board, with the door over it */
.tomo-advent-cell {
  position: relative; aspect-ratio: 1;
  perspective: 700px;
  border-radius: 16px;
  background: var(--bg);
  box-shadow: inset 2px 3px 4px var(--shadow-colour);
}
.tomo-advent-cell.is-opening { z-index: 3; }   /* the swinging door passes over its neighbour */

/* ── The door ──────────────────────────────────────────────────────── */
.tomo-advent-door {
  position: absolute; inset: 0; z-index: 2;
  padding: 0; border: 0; background: none; cursor: pointer;
  transform-style: preserve-3d; transform-origin: 0 50%;
  -webkit-tap-highlight-color: transparent;
}
.tomo-advent-door-front,
.tomo-advent-door-back {
  position: absolute; inset: 0; border-radius: 16px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.tomo-advent-door-front {
  display: flex; align-items: flex-end; justify-content: flex-end;
  padding: 9% 11%; box-sizing: border-box;
  background: var(--door);                   /* flat: flush with the page, no shadow */
}
.tomo-advent-door-back {
  transform: rotateY(180deg);
  background: var(--door-back);
}
.tomo-advent-num {
  font-family: 'Fredoka', sans-serif; font-weight: 700;
  font-size: clamp(1.6rem, 6vw, 2.2rem); line-height: 1;
  color: #fff;
}
.tomo-advent-door:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 16px; }

/* Not yet: no pointer, nothing happens */
.tomo-advent-cell.is-locked .tomo-advent-door { cursor: default; }

/* Opening: swings out on its hinge and fades, then it's gone */
.tomo-advent-cell.is-opening .tomo-advent-door {
  animation: tomoAdventSwing 0.8s ease-in-out forwards;
  pointer-events: none;
}
@keyframes tomoAdventSwing { from { transform: rotateY(0deg); } to { transform: rotateY(-110deg); } }
/* The fade is on the two faces, not the door: opacity on the door
   itself would flatten it and show the front back-to-front. */
.tomo-advent-cell.is-opening .tomo-advent-door-front,
.tomo-advent-cell.is-opening .tomo-advent-door-back { animation: tomoAdventFade 0.8s linear forwards; }
@keyframes tomoAdventFade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ── Behind the door ───────────────────────────────────────────────── */
.tomo-advent-inside {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 8%; box-sizing: border-box;
  border-radius: 16px; overflow: hidden;
}
.tomo-advent-prize {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 100%; height: 100%; min-width: 0;
  text-align: center; text-decoration: none; color: var(--ink);
  font-family: 'Fredoka', sans-serif;
}
.tomo-advent-prize img {
  display: block; width: 100%; min-height: 0; flex: 1; object-fit: contain;
  filter: var(--tomo-drop);
}
.tomo-advent-star { font-size: 1.8rem; line-height: 1; color: var(--door); }
.tomo-advent-label {
  font-size: 0.72rem; font-weight: 600; line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
a.tomo-advent-prize:hover .tomo-advent-label,
button.tomo-advent-prize.is-product:hover .tomo-advent-label,
button.tomo-advent-prize.is-link:hover .tomo-advent-label { text-decoration: underline; }
.tomo-advent-tag {
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--tomo-pink-text);
}
.tomo-advent-code {
  max-width: 100%; overflow-wrap: anywhere;
  font-size: 0.95rem; font-weight: 700; line-height: 1.05; letter-spacing: 0.03em;
}
.tomo-advent-prize.is-coupon .tomo-advent-label { color: var(--muted); font-weight: 500; }
.tomo-advent-prize.is-expired { opacity: 0.55; }
.tomo-advent-prize.is-expired .tomo-advent-code { text-decoration: line-through; }
.tomo-advent-prize.is-empty .tomo-advent-label { color: var(--muted); }
@media (max-width: 860px) {
  .tomo-advent-code { font-size: 0.85rem; }
  .tomo-advent-label { font-size: 0.68rem; }
  .tomo-advent-tag { font-size: 0.55rem; }
}

/* ── Mini game door (js/minigames.js): its sticker plays the game again ── */
.tomo-advent-game {
  display: flex; align-items: center; justify-content: center; gap: 6%;
  width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer;
  outline: none !important; -webkit-tap-highlight-color: transparent;
}
.tomo-advent-game img {
  display: block; height: auto; max-width: none;
  image-rendering: pixelated; image-rendering: crisp-edges;
}

/* A door with its own picture inside (images/advent/door-<day>.gif):
   fills the hole edge to edge, hard pixels. On a game door it's the
   button that plays the game again. */
.tomo-advent-inside.has-pic { padding: 0; }
.tomo-advent-pic {
  display: block; width: 100%; height: 100%; padding: 0; border: 0;
  background: none center / cover no-repeat;
  image-rendering: pixelated; image-rendering: crisp-edges;
  outline: none !important; -webkit-tap-highlight-color: transparent;
}
button.tomo-advent-pic { cursor: pointer; }
button.tomo-advent-pic.is-plain { cursor: default; }        /* a door with nothing but its picture */
button.tomo-advent-prize { padding: 0; border: 0; background: none; cursor: pointer; }

/* ── "Not yet!" bubble over the door ───────────────────────────────── */
.tomo-advent-toast {
  position: absolute; z-index: 5; margin: 0;
  translate: -50% calc(-100% - 8px);
  max-width: min(260px, 80vw); padding: 7px 14px; border-radius: 100px;
  background: var(--ink); color: #fff;
  font-family: 'Fredoka', sans-serif; font-weight: 600; font-size: 0.85rem; text-align: center;
  box-shadow: var(--tomo-shadow);
  pointer-events: none;
  animation: tomoAdventToast 0.25s ease-out;
}
[data-theme="dark"] .tomo-advent-toast { color: #1a1a22; }
@keyframes tomoAdventToast { from { opacity: 0; translate: -50% -80%; } }

/* ── Snow (js/advent.js): a canvas over the whole window, taps go through ── */
.tomo-advent-snow {
  position: fixed; inset: 0; z-index: 50;
  width: 100%; height: 100%;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .tomo-advent-door, .tomo-advent-cell .tomo-advent-door { animation: none !important; }
}
