@charset "UTF-8";

/* Cormorant Garamond (SIL Open Font License, fonts/OFL.txt), served from here: no
   third party sees a visitor. One variable file per style covers every weight; the
   latin-ext part (ő, ű, …) is only fetched when such a letter is on screen. */
@font-face {
  font-family: "Cormorant Garamond"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(/fonts/cormorant-garamond-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Cormorant Garamond"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(/fonts/cormorant-garamond-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Cormorant Garamond"; font-style: italic; font-weight: 300 700; font-display: swap;
  src: url(/fonts/cormorant-garamond-italic-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Cormorant Garamond"; font-style: italic; font-weight: 300 700; font-display: swap;
  src: url(/fonts/cormorant-garamond-italic-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root {
  --bg: #0c1420;
  --bg-2: #142033;
  --ink: #f2ece1;
  --ink-dim: rgba(242, 236, 225, .55);
  --ink-faint: rgba(242, 236, 225, .28);
  --gold: #e3c27e;
  --line: rgba(242, 236, 225, .14);
  --door: #182130;        /* opaque: nothing behind the door may show through */
  --door-hover: #1f2a3b;
  --serif: "Cormorant Garamond", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gap: clamp(6px, 1.4vw, 12px);
  --radius: 10px;
  /* The title above the grid: one line, so its height is known and the grid can make room. */
  --title-size: clamp(1.6rem, 6vw, 3rem);
  --title-gap: clamp(10px, 2.2vh, 22px);
  --title-h: calc(var(--title-size) * 1.15 + var(--title-gap));
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(1200px 700px at 50% -10%, #1f3150 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 110%, #1a2638 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  /* Full-height digits: Cormorant's default old-style ones make a 1 look like an I. */
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Nothing here is for copying: a stray double-click or long press shouldn't select text. */
  -webkit-user-select: none; user-select: none;
}

#snow { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }

/* `hidden` must win over any display rule. */
[hidden] { display: none !important; }

/* The calendar fills the screen, centred, and never scrolls. */
main {
  position: relative; z-index: 1;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

/* ---------- Title ---------- */
.title {
  margin: 0 0 var(--title-gap);
  font-family: var(--serif); font-weight: 500;
  font-size: var(--title-size); line-height: 1.15; letter-spacing: .04em;
  white-space: nowrap;
  /* Gold, lit a little from above, with the same soft glow as today's door. */
  background: linear-gradient(180deg, #f6e2ad 0%, #e3c27e 50%, #b98f4a 100%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(227, 194, 126, .22));
}

/* ---------- Grid ----------
   Fixed, hand-drawn layouts (like a real calendar): numbers scattered, a few
   doors wider or taller, the 24th the biggest. 4×9 on phones, 6×6 on wide screens. */
.grid {
  --cols: 4; --rows: 9;
  /* As wide as possible, but never taller than the screen (4×9 → height = width × 9/4). */
  width: min(100%, 560px, calc((100dvh - 32px - var(--title-h)) * 4 / 9));
  aspect-ratio: calc(var(--cols) / var(--rows));
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  grid-template-areas:
    "d7  d4  d13 d2"
    "d18 d24 d24 d2"
    "d11 d24 d24 d20"
    "d5  d5  d9  d20"
    "d15 d22 d9  d1"
    "d15 d22 d3  d3"
    "d10 d17 d23 d14"
    "d21 d6  d12 d12"
    "d16 d6  d19 d8";
}

@media (min-width: 760px) and (min-aspect-ratio: 4/5) {
  .grid {
    --cols: 6; --rows: 6;
    width: min(92vw, calc(100dvh - 48px - var(--title-h)), 860px);
    grid-template-areas:
      "d7  d7  d13 d2  d18 d11"
      "d4  d24 d24 d2  d5  d5"
      "d20 d24 d24 d9  d15 d22"
      "d20 d1  d3  d9  d15 d10"
      "d17 d14 d3  d21 d6  d6"
      "d23 d12 d12 d16 d19 d8";
  }
}

/* ---------- Doors ---------- */
.cell {
  position: relative;
  perspective: 900px;
  border-radius: var(--radius);
  min-width: 0; min-height: 0;
}

.behind {
  position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden;
  background: #070c14;
  box-shadow: inset 0 0 0 1px var(--line), inset 0 6px 18px rgba(0,0,0,.6);
}
.behind img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .3s ease;
}
.behind img.loaded { opacity: 1; }
.cell:not(.open) .behind > * { visibility: hidden; }
/* The photo has flown out to the viewer: the cell stays empty until it returns. */
.cell.lifted .behind > * { visibility: hidden; }
/* While the door swings, its shadow falls on the photo and fades as it opens. */
.behind::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, rgba(0,0,0,.75), rgba(0,0,0,.25) 45%, transparent 80%);
}
.cell.opening .behind::after { animation: door-shadow 1.3s cubic-bezier(.3,.7,.2,1) forwards; }
@keyframes door-shadow { from { opacity: 1; } to { opacity: 0; } }
.behind .mini {
  position: absolute; left: 8px; bottom: 6px;
  font-family: var(--serif); font-weight: 600; font-size: 1rem; color: var(--ink);
  text-shadow: 0 1px 6px rgba(0,0,0,.8);
}

.door {
  all: unset; cursor: pointer;
  position: absolute; inset: 0;
  transform-origin: left center;
  transition: transform .3s ease;
  border-radius: var(--radius);
  will-change: transform;
}
.door:focus-visible .front { outline: 2px solid var(--gold); outline-offset: 2px; }

/* The door is ONE flat sheet (no backface-visibility, which Chrome draws
   unreliably: the door would sometimes flash see-through). Its two looks are
   stacked, and the swap happens by opacity at the moment the door is edge-on to
   the viewer, so it can't be seen. */
.face {
  position: absolute; inset: 0; border-radius: var(--radius);
}
.front {
  background: linear-gradient(155deg, rgba(255,255,255,.09), rgba(255,255,255,.03) 55%), var(--door);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  transition: background .25s ease, border-color .25s ease;
}
.front .num {
  font-family: var(--serif); font-weight: 500; line-height: 1;
  font-size: clamp(1.45rem, 6.6vw, 2.45rem);
  color: var(--ink);
}
.cell.big .front .num { font-size: clamp(2.9rem, 15.5vw, 5.5rem); }
/* The inside of the door: plain card, lit a little from the opening. */
.back {
  opacity: 0;
  background: linear-gradient(90deg, #2a3850, #1a2639 70%, #141e2e);
  border: 1px solid rgba(242,236,225,.18);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.02);
}

@media (hover: hover) {
  .cell.unlocked:not(.open) .door:hover .front { background-color: var(--door-hover); border-color: rgba(242,236,225,.3); }
  .cell.unlocked:not(.open) .door:hover { transform: rotateY(-8deg); }
}

.cell.locked .front .num { color: var(--ink-faint); }
/* The swing: fast through the first part, slowing to rest at 115°. The
   keyframe at 84° is where a door of this size is seen edge-on (with the
   900px perspective), so that's where the faces swap. */
.cell.opening .door { animation: door-swing 1.3s forwards; }
.cell.opening .front { animation: front-off 1.3s forwards; }
.cell.opening .back { animation: back-on 1.3s forwards; }
@keyframes door-swing {
  0%   { transform: rotateY(0deg);    animation-timing-function: cubic-bezier(.4, 0, .8, .7); }
  52%  { transform: rotateY(-84deg);  animation-timing-function: cubic-bezier(.1, .45, .3, 1); }
  100% { transform: rotateY(-115deg); }
}
@keyframes front-off { 0% { opacity: 1; animation-timing-function: step-end; } 52%, 100% { opacity: 0; } }
@keyframes back-on   { 0% { opacity: 0; animation-timing-function: step-end; } 52%, 100% { opacity: 1; } }
.cell.open.instant .behind img { transition: none; }
/* Once opened (and the full view shown), the door is gone; only the photo stays.
   The button stays as an invisible layer over the photo, so it can still be clicked or focused. */
.cell.done .door { transform: none; transition: none; }
.cell.done .face { display: none; }
.cell.done .door:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Today's door, not yet opened: a soft golden glow. */
.cell.today:not(.open) .front {
  border-color: rgba(227, 194, 126, .7);
  box-shadow: 0 0 0 1px rgba(227,194,126,.25), 0 0 24px rgba(227,194,126,.25);
  animation: glow 2.6s ease-in-out infinite;
}
.cell.today:not(.open) .front .num { color: var(--gold); }
@keyframes glow {
  50% { box-shadow: 0 0 0 1px rgba(227,194,126,.4), 0 0 34px rgba(227,194,126,.42); }
}

.cell.shake .door { animation: shake .45s ease; }
@keyframes shake {
  20% { transform: translateX(-4px) rotateY(-4deg); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px) rotateY(-2deg); }
  80% { transform: translateX(2px); }
}

/* The swinging door sticks out of its cell; keep it above every neighbour
   (opened or not) while it moves. Once done, the door is gone anyway. */
.cell.opening { z-index: 3; }
.cell.unlocked { cursor: pointer; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 20;
  padding: 10px 18px; border-radius: 999px;
  background: rgba(20, 32, 51, .92); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-family: var(--serif); font-style: italic; color: var(--ink);
  transition: opacity .3s ease, transform .3s ease;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Viewer ---------- */
.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  /* Transparent: the ink canvas paints the background as it spreads. */
  background: transparent;
  color: var(--ink);
  overflow-y: auto;
  /* Chrome's built-in styles make an open modal dialog selectable again; undo that. */
  -webkit-user-select: none; user-select: none;
}
body:has(.viewer[open]) { overflow: hidden; }
.viewer::backdrop { background: transparent; }

.ink { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .96; }

/* The photo while it flies between its cell and the viewer. */
.flyer {
  position: fixed; z-index: 5; overflow: hidden; pointer-events: none;
  will-change: left, top, width, height;
}
.flyer img { width: 100%; height: 100%; object-fit: cover; display: block; }

.viewer-body {
  position: relative; z-index: 1;
  margin: 0 auto; min-height: 100%;
  padding: max(56px, env(safe-area-inset-top)) 20px max(40px, env(safe-area-inset-bottom));
  max-width: 900px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(20px, 4vh, 36px);
}
.viewer-body:focus { outline: none; }
.viewer-photo { width: 100%; display: flex; justify-content: center; }
.viewer-photo img {
  max-width: 100%; max-height: 62dvh; border-radius: 6px; display: block;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  opacity: 0; transition: opacity .25s ease;
}
.viewer.ready .viewer-photo img { opacity: 1; }

/* The text comes in after the photo has landed, one line after the other. */
.viewer figcaption > *, .viewer .viewer-close {
  opacity: 0; transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
}
.viewer.ready figcaption > *, .viewer.ready .viewer-close {
  opacity: 1; transform: none;
  transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1);
}
.viewer.ready figcaption > :nth-child(2) { transition-delay: .12s; }
.viewer.ready figcaption > :nth-child(3) { transition-delay: .3s; }
.viewer.ready figcaption > :nth-child(4) { transition-delay: .42s; }
.viewer.ready .viewer-close { transition-delay: .5s; }

figcaption { text-align: center; max-width: 640px; }
.viewer-day {
  margin: 0 0 14px; font-size: .72rem; letter-spacing: .3em; text-transform: uppercase; color: var(--gold);
}
blockquote {
  margin: 0; font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: clamp(1.3rem, 4vw, 1.75rem); line-height: 1.5; text-wrap: pretty;
}
/* Escaped, so the quote marks survive whatever encoding a browser assumes. */
blockquote::before { content: "\201E"; }  /* „ */
blockquote::after { content: "\201D"; }   /* ” */
.viewer-source { margin: 16px 0 0; color: var(--ink-dim); font-size: .92rem; }
.viewer-source .work { font-style: italic; }
.viewer-caption { margin: 18px 0 0; color: var(--ink-faint); font-size: .85rem; }
.viewer-caption:empty { display: none; }

.viewer button {
  all: unset; cursor: pointer; position: fixed; z-index: 3;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--ink);
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  box-sizing: border-box;
  transition: background .2s ease;
}
.viewer button svg { display: block; }
.viewer button:hover { background: rgba(255,255,255,.12); }
.viewer button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.viewer .viewer-close { top: max(12px, env(safe-area-inset-top)); right: 12px; }

@media (prefers-reduced-motion: reduce) {
  .door, .behind img, .viewer-photo img, .viewer figcaption > *, .viewer .viewer-close { transition: none !important; }
  .cell.opening .behind::after, .cell.opening .door, .cell.opening .face { animation: none; }
  .cell.today:not(.open) .front { animation: none; }
}
