@font-face { font-family: "Archivo"; font-weight: 800; font-display: swap; src: url(/fonts/archivo-800.woff2) format("woff2"); }
@font-face { font-family: "Space Mono"; font-weight: 400; font-display: swap; src: url(/fonts/spacemono-400.woff2) format("woff2"); }
@font-face { font-family: "Space Mono"; font-weight: 700; font-display: swap; src: url(/fonts/spacemono-700.woff2) format("woff2"); }

:root {
  color-scheme: light;
  --ink: #111111;
  --paper: #F8F4EE;
  --muted: #6B6460;
  --lilac: #A88BE0;
  --lilac-soft: #EFE8F8;
  --mustard: #F2C75C;
  --tape: #E9805A;
  --red: #E0302F;
  --red-deep: #7A1414;
  --flag: 0px;
  --cols: 13;
  --rows: 21;
  --display: "Archivo", "Arial Black", "Helvetica Neue", sans-serif;
  --mono: "Space Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ink); }
body {
  margin: 0; min-height: 100dvh; color: var(--ink); background: var(--ink);
  padding: calc(env(safe-area-inset-top) + var(--flag)) calc(env(safe-area-inset-right) + var(--flag))
           calc(env(safe-area-inset-bottom) + var(--flag)) calc(env(safe-area-inset-left) + var(--flag));
  font: 15px/1.5 var(--mono);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.mono { font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; }

.screen {
  min-height: calc(100dvh - 2 * var(--flag) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  background: var(--paper); border: 2px solid var(--ink);
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--lilac); border-bottom: 4px solid var(--ink); padding: 10px 14px;
}
.brand { font: 800 22px/1 var(--display); letter-spacing: -.04em; }
.sub { font-size: 9px; margin-top: 4px; letter-spacing: .14em; }
.top-actions { display: flex; gap: 10px; }
.chip {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  background: var(--mustard); border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 10px; min-height: 36px; border-radius: 0;
}
.chip.square { width: 38px; padding: 0; font-size: 18px; letter-spacing: 0; }
.chip:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

main { max-width: 600px; margin: 0 auto; padding: 12px 12px 20px; }

/* ---------- type ---------- */
h1 { font: 800 clamp(48px, 15vw, 64px)/.92 var(--display); letter-spacing: -.045em; margin: 4px 0 6px; }
h1.day { font-size: clamp(44px, 13vw, 58px); }
.label { font-size: 11px; color: var(--muted); margin: 0; }
.body { font-size: 12px; line-height: 1.7; color: #3D3835; margin: 14px 0 22px; }
.small { font-size: 11px; line-height: 1.6; color: #3D3835; margin: 6px 0; }

/* ---------- panels ---------- */
.panel { position: relative; background: #fff; border: 2px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); padding: 18px 14px 14px; }
.tag {
  position: absolute; top: -12px; left: 10px; font-size: 10px;
  background: var(--mustard); border: 2px solid var(--ink); padding: 1px 7px;
}
input[type="date"], input[type="time"] {
  font: 16px var(--mono); color: var(--ink); background: var(--paper);
  border: 2px solid var(--ink); border-radius: 0; padding: 10px; min-height: 46px; width: 100%;
}
hr { border: none; border-top: 2px dashed var(--ink); margin: 14px 0; }

/* ---------- big red button ---------- */
.press-row { display: flex; align-items: center; gap: 18px; margin: 18px 0 4px; }
.press-row .small { flex: 1; }
.big-red {
  flex: none; width: 104px; height: 104px; border-radius: 50%; padding: 0;
  background: radial-gradient(circle at 38% 30%, #FF6A5E 0 18%, var(--red) 46%, #B81F22 100%);
  border: 3px solid var(--ink);
  box-shadow: 0 8px 0 var(--red-deep), 0 8px 0 3px var(--ink), inset 0 -4px 0 rgba(0, 0, 0, .15);
  color: #fff; font: 700 13px/1.15 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  transition: transform .06s, box-shadow .06s;
  margin-bottom: 8px;
}
.big-red:active, .big-red.pressing { transform: translateY(7px); box-shadow: 0 1px 0 var(--red-deep), 0 1px 0 3px var(--ink), inset 0 -2px 0 rgba(0, 0, 0, .15); }
.big-red.done {
  background: radial-gradient(circle at 38% 30%, #F2EEE8 0 18%, #D9D2C8 50%, #BDB4A8 100%);
  box-shadow: 0 3px 0 #8C8378, 0 3px 0 3px var(--ink); transform: translateY(5px); color: var(--ink); cursor: default;
}
.big-red:focus-visible { outline: 3px solid var(--lilac); outline-offset: 4px; }

/* ---------- tape window + tiles ---------- */
.tape { border: 2px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); margin: 8px auto 6px; background: var(--ink); width: fit-content; max-width: 100%; }
.tape-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--tape); border-bottom: 2px solid var(--ink); font-size: 10px; padding: 5px 8px;
}
.dots { display: flex; gap: 4px; }
.dots i { width: 8px; height: 8px; display: block; background: #C94A4A; }
.dots i:nth-child(2) { background: var(--mustard); }
.dots i:nth-child(3) { background: var(--lilac); }
.frame {
  position: relative; aspect-ratio: var(--cols) / var(--rows);
  width: min(calc(100vw - 28px), 560px, calc((100dvh - 372px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * var(--cols) / var(--rows))); min-width: 220px;
  overflow: hidden; background: #E9DDD0;
}
.baby { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; user-select: none; -webkit-user-select: none; }
.tiles {
  position: absolute; inset: 0; display: grid;
  grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr);
}
.tile {
  background-color: var(--paper); background-repeat: no-repeat; background-position: center; background-size: 82%;
  image-rendering: pixelated; box-shadow: inset 0 0 0 .5px rgba(17, 17, 17, .22);
}
.tile.alt { background-color: var(--lilac-soft); }
.tile.gone { visibility: hidden; }
.tile.leaving { animation: leave .7s steps(7) forwards; z-index: 2; }
@keyframes leave {
  0% { transform: none; opacity: 1; }
  40% { transform: translateY(-30%) scale(1.25); opacity: 1; }
  100% { transform: translateY(-140%) scale(.2); opacity: 0; }
}
.tile.today {
  z-index: 3; cursor: pointer; background-color: #FFF3C4;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--mustard);
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--red); } }
.tile.today.leaving { animation: leave-big .9s steps(9) forwards; }
@keyframes leave-big {
  0% { transform: scale(1); opacity: 1; }
  35% { transform: scale(2.4); opacity: 1; }
  100% { transform: translateY(-260%) scale(.3); opacity: 0; }
}
.fx { position: absolute; inset: 0; pointer-events: none; }
.particle {
  position: absolute; width: 8px; height: 8px; background: var(--c); box-shadow: 0 0 0 1px var(--ink);
  animation: burst 1s steps(10) forwards;
}
@keyframes burst {
  from { transform: translate(-50%, -50%); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))); opacity: 0; }
}
.done-frame { outline: 4px solid var(--mustard); }

/* ---------- daily words ---------- */
.words { margin-top: 20px; }
.quote { font: 800 18px/1.25 var(--display); letter-spacing: -.02em; margin: 6px 0 6px; }
.source { font-size: 10px; color: var(--muted); margin: 0; }
.note { font-size: 12px; line-height: 1.7; color: #3D3835; margin: 0; text-transform: none; letter-spacing: .02em; }
.note::before { content: "P.S. "; font-weight: 700; }

/* ---------- dialogs ---------- */
dialog.sheet {
  overflow: auto; padding: 0; width: min(92vw, 420px); border: 2px solid var(--ink); border-radius: 0;
  background: var(--paper); color: var(--ink); box-shadow: 8px 8px 0 var(--ink); max-height: 86dvh;
}
dialog.sheet::backdrop { background: rgba(17, 17, 17, .55); }
.sheet-body { padding: 16px; }
.sheet h2 { font: 800 26px/1.05 var(--display); letter-spacing: -.03em; margin: 6px 0 4px; }
.day-fruit { display: block; width: 96px; height: 96px; image-rendering: pixelated; margin: 4px auto 6px; }
#day-card .sheet-body { text-align: center; }
.words-in-card { position: relative; text-align: left; background: #fff; border: 2px solid var(--ink); padding: 18px 12px 12px; margin: 18px 0 6px; }
.btn-yellow, .btn-white {
  display: block; width: 100%; min-height: 48px; margin-top: 12px; border-radius: 0;
  border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); font-size: 12px;
}
.btn-yellow { background: var(--mustard); }
.btn-white { background: #fff; }
.btn-yellow:active, .btn-white:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.danger { color: #A3243A; }
.row { display: flex; gap: 10px; align-items: center; }
.row input { flex: 1; }
.row .btn-yellow { margin-top: 0; width: auto; padding: 0 14px; }

.update-bar {
  position: fixed; z-index: 40; left: calc(var(--flag) + 10px); right: calc(var(--flag) + 10px);
  bottom: calc(env(safe-area-inset-bottom) + var(--flag) + 10px);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border: 2px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); padding: 8px 8px 8px 12px; font-size: 11px;
}
.update-bar .btn-yellow { width: auto; margin: 0; padding: 0 14px; min-height: 40px; }

/* ---------- admin preview ---------- */
.admin-bar { background: var(--ink); color: #fff; border: 2px solid var(--ink); padding: 8px 10px 10px; margin: 0 0 14px; box-shadow: 5px 5px 0 var(--lilac); }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.admin-tag { margin: 0; font-size: 10px; color: var(--mustard); }
.admin-link { background: none; border: none; color: var(--lilac); font-size: 10px; text-decoration: underline; min-height: 32px; padding: 0; }
.admin-label { margin: 0 0 2px; font-size: 11px; }
.admin-row { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.admin-row button { flex: 1; min-height: 42px; border: 2px solid #fff; background: #222; color: #fff; font-size: 11px; border-radius: 0; white-space: nowrap; }
.admin-row button:disabled { opacity: .4; }
#adm-prev, #adm-next { flex: 0 0 46px; }
#adm-range { flex: 1; accent-color: var(--mustard); min-width: 0; height: 40px; }
body.admin .frame { width: min(calc(100vw - 28px), 560px, calc((100dvh - 430px) * var(--cols) / var(--rows))); }

@media (prefers-reduced-motion: reduce) {
  .tile.today { animation: none; }
  .tile.leaving, .tile.today.leaving { animation: fade .3s forwards; }
  @keyframes fade { to { opacity: 0; } }
}

/* ---------- today's painting ---------- */
.darshan { margin: 4px 0 12px; }
.darshan img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 20%; border: 2px solid var(--ink); background: #E9DDD0; }
.darshan figcaption { font-size: 9px; line-height: 1.5; color: var(--muted); margin-top: 6px; }
.darshan a { color: inherit; }

/* ---------- compact status + press row ---------- */
.status-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 0 2px; }
.status-row h1.day { font-size: clamp(34px, 10vw, 46px); margin: 0; white-space: nowrap; }
.status-meta { text-align: right; padding-bottom: 4px; }
.status-meta .label { font-size: 9px; line-height: 1.6; }
.board .press-row { margin: 14px 2px 0; gap: 14px; }
.board .big-red { width: 84px; height: 84px; font-size: 12px; }
.press-side { flex: 1; min-width: 0; }
.press-side .small { margin: 0 0 6px; }
.recall { margin-top: 0 !important; min-height: 40px !important; font-size: 10px !important; width: auto !important; padding: 0 12px; display: inline-block; }
.tiles { cursor: default; }
.tile.today { cursor: pointer; }
.tile.wobble { animation: wobble .25s steps(3); }
@keyframes wobble { 33% { transform: rotate(-6deg); } 66% { transform: rotate(6deg); } }

/* ---------- flip card that grows out of the tile ---------- */
.card-layer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.card-backdrop { position: absolute; inset: 0; background: rgba(17, 17, 17, .6); opacity: 0; transition: opacity .35s; }
.card-layer.open .card-backdrop { opacity: 1; }
.card-shell {
  position: relative; width: min(86vw, 380px); height: min(76dvh, 620px); perspective: 1400px;
  transform-origin: 0 0; will-change: transform;
}
.card-shell.animating { transition: transform .45s cubic-bezier(.2, .9, .3, 1.05), opacity .45s; }
.card-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .6s cubic-bezier(.3, .2, .2, 1); }
.card-inner.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--paper);
  border: 2px solid var(--ink); box-shadow: 8px 8px 0 var(--ink);
  -webkit-backface-visibility: hidden; backface-visibility: hidden; overflow: hidden;
}
.face.back { transform: rotateY(180deg); background: #fff; }
.card-x { background: none; border: none; font: 700 20px/1 var(--mono); padding: 0 4px; min-width: 36px; min-height: 30px; }
.face .darshan { flex: 1; min-height: 0; margin: 10px 10px 0; }
.face .darshan img { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; object-position: 50% 25%; }
.credit { font-size: 8px; line-height: 1.5; color: var(--muted); margin: 6px 10px 0; }
.credit a { color: inherit; }
.flip-hint {
  margin: 10px; min-height: 46px; border: 2px solid var(--ink); background: var(--mustard);
  box-shadow: 3px 3px 0 var(--ink); font-size: 11px;
}
.flip-hint:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.back-body { flex: 1; overflow: auto; padding: 14px 14px 4px; }
.size-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.c-fruit { width: 64px; height: 64px; image-rendering: pixelated; flex: none; background: var(--paper); border: 2px solid var(--ink); }
.size-title { font: 800 18px/1.1 var(--display); letter-spacing: -.02em; margin: 0 0 2px; }
.back-body .quote { font-size: 20px; }
.stage { margin-top: 12px; }
@media (prefers-reduced-motion: reduce) {
  .card-shell.animating, .card-inner { transition: none; }
}
.tile.ghost { animation: settle .45s steps(5) forwards; }
@keyframes settle { from { opacity: .9; transform: scale(1.3); } to { opacity: 0; transform: scale(.6); } }
/* WebKit only culls a back face when each face has its own 3D transform. */
.face.front { transform: rotateY(0deg) translateZ(1px); }
.face.back { transform: rotateY(180deg) translateZ(1px); }
.back-body { display: flex; flex-direction: column; justify-content: center; }
/* Swap faces at the half-way point too, so the flip is right even where back-face culling isn't supported. */
.face { transition: visibility 0s .3s; }
.face.back { visibility: hidden; }
.card-inner.flipped .face.back { visibility: visible; }
.card-inner.flipped .face.front { visibility: hidden; }

/* Buju days: just the photo and "Buju says whatsup". */
.card-shell.buju .credit { font: 800 20px/1.1 var(--display); letter-spacing: -.02em; color: var(--ink); text-transform: none; }
.card-shell.buju .note, .card-shell.buju .source, .card-shell.buju hr { display: none; }
.card-shell.buju .face.front .darshan img { object-position: 50% 40%; }
.card-shell.buju .credit .dot { display: none; }

/* Story days: a little longer, so a calmer type size. */
.card-shell.story .back-body .quote { font: 400 15px/1.6 var(--mono); letter-spacing: .01em; text-transform: none; }

/* ---------- Punjabi gift: a 14-day loading bar that opens a voucher ---------- */
:root { --saffron: #F28C28; --navy: #1E3A8A; }
/* Phulkari frame: diamonds in the colours of Punjabi embroidery around a white card. */
.gift-strip {
  display: block; width: 100%; margin: 12px 0 0; padding: 7px; text-align: left; border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink); background-color: var(--saffron);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Cpath d='M7 1l6 6-6 6-6-6z' fill='%23C2185B'/%3E%3Cpath d='M7 4.5l2.5 2.5-2.5 2.5-2.5-2.5z' fill='%23FFD54F'/%3E%3C/svg%3E");
}
.gift-strip:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.gift-inner { display: flex; align-items: center; gap: 9px; background: #fff; border: 2px solid var(--ink); padding: 6px 8px; }
.gift-icon { width: 36px; height: 36px; flex: none; }
.gift-text { flex: 1; min-width: 0; }
.gift-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
#gift-title { font: 800 16px/1.1 var(--display); letter-spacing: -.01em; }
#gift-pct { font-size: 10px; font-weight: 700; }
.gift-bar { display: grid; grid-template-columns: repeat(14, 1fr); gap: 2px; margin: 5px 0 4px; }
.gift-bar i { height: 8px; border: 1.5px solid var(--ink); background: #fff; }
.gift-bar i.on { background: var(--saffron); }
.gift-sub { display: block; font-size: 9px; color: var(--muted); }
.gift-strip.ready { animation: gift-glow 1.4s steps(2) infinite; }
.gift-strip.ready .gift-inner { background: #FFF4E5; }
.gift-strip.ready .gift-bar i { background: var(--navy); }
.gift-strip.ready .gift-sub { color: var(--ink); font-weight: 700; }
.gift-strip.ready .gift-icon { animation: gift-hop 1s steps(2) infinite; }
@keyframes gift-glow { 50% { box-shadow: 4px 4px 0 var(--ink), 0 0 0 3px var(--mustard); } }
@keyframes gift-hop { 50% { transform: translateY(-3px) rotate(-6deg); } }

.gift-layer { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 16px; }
.gift-layer.open .card-backdrop { opacity: 1; }
.voucher {
  position: relative; width: min(88vw, 400px); height: min(84dvh, 700px); display: flex; flex-direction: column;
  background: var(--paper); border: 2px solid var(--ink); box-shadow: 8px 8px 0 var(--saffron), 8px 8px 0 2px var(--ink);
  transform: scale(.4) rotate(-6deg); opacity: 0; transition: transform .45s cubic-bezier(.2, .9, .3, 1.15), opacity .3s;
}
.gift-layer.open .voucher { transform: none; opacity: 1; }
.voucher .tape-bar { background: var(--saffron); }
.v-art { position: relative; flex: 1; min-height: 0; overflow: hidden; border-bottom: 2px dashed var(--ink); }
.v-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; display: block; }
/* Wrapping paper that splits open the first time a gift is unwrapped. */
.v-wrap { position: absolute; inset: 0; display: none; pointer-events: none; }
.v-wrap i { position: absolute; top: 0; bottom: 0; width: 50%; background:
  linear-gradient(90deg, transparent calc(100% - 9px), var(--navy) 0) , linear-gradient(transparent 44%, var(--navy) 0 calc(44% + 18px), transparent 0), var(--saffron);
  transition: transform .7s cubic-bezier(.6, 0, .3, 1) .35s; }
.v-wrap .l { left: 0; }
.v-wrap .r { right: 0; transform-origin: right; background:
  linear-gradient(90deg, var(--navy) 9px, transparent 0), linear-gradient(transparent 44%, var(--navy) 0 calc(44% + 18px), transparent 0), var(--saffron); }
.voucher.unwrap .v-wrap { display: block; }
.gift-layer.open .voucher.unwrap .v-wrap .l { transform: translateX(-101%); }
.gift-layer.open .voucher.unwrap .v-wrap .r { transform: translateX(101%); }
.v-panel { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px 14px; color: #fff; background: rgba(17, 17, 17, .8); }
.v-kicker { margin: 0; font-size: 10px; color: var(--mustard); }
.v-head { margin: 4px 0 6px; font: 800 24px/1.05 var(--display); letter-spacing: -.02em; }
.v-meta { margin: 0; font-size: 9px; opacity: .85; }
.v-stamp {
  position: absolute; top: 18%; right: 8%; padding: 6px 12px; font-size: 18px; font-weight: 700; color: var(--red);
  border: 3px solid var(--red); background: rgba(248, 244, 238, .85); transform: rotate(-12deg);
}
.v-foot { padding: 10px 12px 12px; }
.v-foot .btn-yellow { margin: 0; width: 100%; }
.v-foot .btn-yellow.given { background: #fff; }
.v-credit { margin: 6px 0 0; font-size: 8px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .voucher, .v-wrap i, .gift-strip.ready, .gift-strip.ready .gift-icon { transition: none; animation: none; } }
