/* Home 03 the doors: the four products as four paper doors, each cut from the paper of the page it opens (kraft
   for the diary, Naalai blue for Nila, sun yellow for Kuru, pink for Kids games, whose window is a drawn game room:
   a maze, memory cards with a matched pair and a jigsaw piece). An arched window at the top shows the character in its
   own little scene; the name, who it is for, the price and one line sit on the lower panel. The whole door is one
   link (the name's link stretches over it). On a fine pointer or keyboard focus the leaf swings open a little on its
   hinge (a critically damped spring, transform only) and warm light shows in the doorway behind it; on touch it opens
   a crack in the middle of the screen and swings wide on a tap (03-doors.js).
   The doors drop onto the page on twos when they are seen, their shadows settling under them. Reduced motion: still,
   closed, readable. */

.doors { overflow-x: clip; }
.doors__head { max-width: 44rem; }
.doors__lead { margin-top: clamp(12px, 1.4vw, 18px); max-width: 34em; font-size: var(--t-lead); line-height: 1.55; color: var(--ink-2); }

.doors__row { margin-top: clamp(40px, 5vw, 72px); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(18px, 2.4vw, 34px); align-items: stretch; }

.door { --door-c: var(--kraft); --door-tex: url(/assets/art/textures/kraft-tile.webp); --door-tex-size: 512px 512px; --door-blend: normal;
  --door-fg: var(--ink); --door-fg-2: #57391A; --door-go: var(--blue-deep); --door-sky: #CFE3FF; --door-ground: #A6D38C;
  --arch: clamp(96px, 9.6vw, 140px);
  --door-r: 50% 50% 14px 16px / var(--arch) var(--arch) 14px 16px;
  position: relative; perspective: 1500px; perspective-origin: 30% 50%; isolation: isolate; rotate: var(--door-tilt, 0deg); }
.door--diary { --door-tilt: -.8deg; }
.door--nila { --door-c: var(--blue); --door-tex: url(/assets/art/textures/blue-paper-tile.webp); --door-fg: #FFFFFF; --door-fg-2: #E3E9FF; --door-go: var(--lemon);
  --door-sky: var(--night); --door-ground: #22433A; --door-tilt: .6deg; }
.door--games { --door-c: var(--pink); --door-tex: url(/assets/art/textures/grain-soft-tile.webp); --door-tex-size: 256px 256px; --door-blend: multiply;
  --door-fg: var(--ink); --door-fg-2: #8A2440; --door-sky: var(--mint); --door-ground: #E9C893; --door-tilt: .5deg; }
.door--kuru { --door-c: var(--sun); --door-tex: url(/assets/art/textures/grain-soft-tile.webp); --door-tex-size: 256px 256px; --door-blend: multiply;
  --door-fg: var(--ink); --door-fg-2: #5A3A06; --door-sky: #FFF4E4; --door-ground: transparent; --door-tilt: -.4deg; }

/* the doorway behind the leaf: warm lamp light, seen when the door swings open */
.door__way { position: absolute; inset: 0; z-index: 0; border-radius: var(--door-r);
  background: radial-gradient(110% 70% at 92% 62%, #FFF7D1 0, #FFD45A 44%, #F29A2E 100%);
  box-shadow: inset 0 0 0 5px rgba(90, 42, 0, .3), inset 14px 0 26px rgba(90, 42, 0, .42); }
.door__leaf { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: 14px 14px 24px; border-radius: var(--door-r);
  background: var(--door-c) var(--door-tex) 0 0 / var(--door-tex-size); background-blend-mode: var(--door-blend); color: var(--door-fg);
  transform-origin: 0 50%; transition: transform 900ms var(--m-spring, ease);
  box-shadow: var(--pk-edge-light), 0 1px 1.5px rgba(90, 42, 0, .3), 0 26px 40px -22px rgba(90, 42, 0, .55); }
.door--nila .door__leaf { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 1px 1.5px rgba(11, 26, 85, .4), 0 26px 40px -22px rgba(11, 26, 85, .6); }
/* the hinge side: two small paper hinges */
.door__leaf::before { content: ""; position: absolute; left: -3px; top: 32%; width: 7px; height: 30px; border-radius: 3px; z-index: 2;
  background: #C9CFDB; box-shadow: 0 calc(var(--arch) * 1.6) 0 #C9CFDB, 0 1px 1px rgba(11, 26, 85, .35); }

/* the arched window: a little scene for each character */
.door__window { position: relative; aspect-ratio: 1 / .9; overflow: hidden; isolation: isolate;
  border-radius: 50% 50% 10px 10px / calc(var(--arch) - 12px) calc(var(--arch) - 12px) 10px 10px; background: var(--door-sky);
  box-shadow: inset 0 4px 12px rgba(40, 20, 0, .3), inset 0 0 0 4px rgba(255, 255, 255, .3); }
.door--nila .door__window { background: var(--night) url(/assets/art/textures/night-paper-tile.webp) 0 0 / 512px 512px; }
.door__window::before { content: ""; position: absolute; left: -6%; right: -6%; bottom: -10%; height: 24%; z-index: 0; border-radius: 50% 50% 0 0 / 40% 46% 0 0;
  background: var(--door-ground); box-shadow: 0 -1px 0 rgba(255, 255, 255, .35), 0 -6px 12px -8px rgba(40, 20, 0, .35); }
.door__window::after { content: ""; position: absolute; inset: 0; z-index: 9; pointer-events: none;
  background: url(/assets/art/textures/grain-tile.webp) 0 0 / 256px 256px; mix-blend-mode: multiply; opacity: .35; }
.door__window > * { position: absolute; z-index: 1; display: block; max-width: none; height: auto; }

/* diary: the morning sun with googly eyes, the bag and the tiffin waiting by the door */
/* .char and .char__part (a character drawn as its parts, for googly eyes) live in _shared/life.css */
.door__sun { left: 50%; top: 9%; width: 50%; translate: -50% 0; rotate: 6deg; }
.door__thing--bag { left: 9%; bottom: 7%; width: 19%; }
.door__thing--tiffin { right: 11%; bottom: 7%; width: 13%; }
/* Nila: the moon over the school at night */
.door__nila { left: 27%; top: 7%; width: 48%; rotate: -6deg; }
.door__star { width: 7%; }
.door__star--a { left: 14%; top: 22%; }
.door__star--b { right: 13%; top: 14%; width: 10%; }
.door__thing--school { left: 50%; bottom: 3%; width: 74%; translate: -50% 0; filter: brightness(.62) saturate(.8); }
/* Kuru: Kuru's stills are drawn on cream paper (#FFF4E4), so his window is that same cream paper. His picture stands
   on the window's floor, centred and sized by width only (height auto), so a re-rendered Kuru with new sizes drops in
   without new numbers. The cloud is pinned over the top corner, where his canvas is empty paper. */
.door--kuru .door__window::before { display: none; }
.door__cloud { left: 3%; top: 5%; width: 24%; z-index: 2; }
.door__kuru { left: 50%; bottom: 0; width: 56%; translate: -50% 0; } /* his still is cut tight: this leaves the arch some sky above his cap */
.door__kuru img { display: block; width: 100%; height: auto; }

/* Kids games: a little game room on the table, drawn here (a maze, memory cards with a matched pair, a jigsaw piece) */
.door__maze { left: 7%; top: 26%; width: 38%; aspect-ratio: 1; padding: 4%; border-radius: 12% 14% 12% 10%; background: var(--card); rotate: -8deg;
  box-shadow: inset 0 1px 0 #FFFFFF, 0 1px 1px rgba(90, 42, 0, .3), 0 8px 12px -8px rgba(90, 42, 0, .45); }
.door__maze svg { display: block; width: 100%; height: 100%; }
.door__cards { right: 7%; top: 17%; width: 40%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7%; rotate: 6deg; }
.door__cards i { display: grid; place-items: center; aspect-ratio: 3 / 4; border-radius: 14%; background: var(--card);
  box-shadow: inset 0 1px 0 #FFFFFF, 0 1px 1px rgba(90, 42, 0, .3), 0 6px 10px -6px rgba(90, 42, 0, .45); }
.door__cards .is-back { background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .55) 0 14%, transparent 15%) 0 0 / 50% 33.3%, var(--blue); }
.door__cards img { width: 66%; height: auto; }
.door__piece { left: 41%; bottom: 7%; width: 27%; rotate: 14deg; }
.door__piece svg { display: block; width: 100%; height: auto; }

/* the lower panel */
.door__panel { flex: 1; display: flex; flex-direction: column; padding: 20px 30px 0 10px; }
.door__name { font-size: clamp(23px, 2vw, 30px); line-height: 1.08; color: var(--door-fg); }
.door__link { color: inherit; text-decoration: none; }
/* the name's link covers the whole door */
.door__link::after { content: ""; position: absolute; inset: 0; z-index: 4; border-radius: var(--door-r); }
.door__link:focus-visible { outline: none; }
.door__link:focus-visible::after { outline: 3px solid var(--blue); outline-offset: 5px; }
.door--nila .door__link:focus-visible::after { outline-color: var(--ink); }
.door__for { margin-top: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font: 800 16px/1.35 var(--font-body); color: var(--door-fg-2); }
.door__price { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 12px; border-radius: 15px; background: var(--card); color: var(--ink);
  font: 800 15px/1.2 var(--font-body); box-shadow: inset 0 1px 0 #FFFFFF, 0 1px 1px rgba(90, 42, 0, .22); }
/* Round 3: the diary's "Free" is a green rubber stamp pressed on the door (paper-kit .pk-rubber), never a pill */
.door__stamp { --pk-rubber-fs: 26px; --pk-rubber-turn: -7deg; margin: -2px 0 -2px 2px; }
.door__line { margin-top: 12px; font: 650 var(--t-body)/1.5 var(--font-body); color: var(--door-fg); }
.door__go { margin-top: auto; padding-top: 20px; display: inline-flex; align-items: center; gap: 10px; font: 800 18px/1 var(--font-body); color: var(--door-go); }
.door__go::after { content: ""; width: 20px; height: 13px; background: currentColor; transition: translate var(--m-small, 400ms) var(--m-settle, ease);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 12'%3E%3Cpath d='M1 6h14M11 1.5 15.5 6 11 10.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 12'%3E%3Cpath d='M1 6h14M11 1.5 15.5 6 11 10.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
.door__knob { position: absolute; right: 16px; top: auto; bottom: 34px; width: 19px; height: 19px; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 34% 30%, #FFF3C4 0 16%, #E8A93A 46%, #A86A16 100%); box-shadow: 0 2px 2px rgba(60, 30, 0, .45), 0 0 0 3px rgba(255, 255, 255, .18); }

/* the swing: the leaf opens a few degrees as the door arrives (paper motion, data-pm="leaf"); keyboard focus opens it a little. A pointer over it does nothing. */
@media (prefers-reduced-motion: no-preference) {
  .door:has(.door__link:focus-visible) .door__leaf { transform: rotateY(17deg); }
}
.door:active .door__leaf { transition-duration: 160ms; transform: rotateY(22deg) scale(.995); }
/* touch: a crack of light as the door passes the middle of the screen; a tap swings it wide before its page loads */
@media (prefers-reduced-motion: no-preference) {
  .door.is-peek .door__leaf { transform: rotateY(11deg); }
  .door.is-open .door__leaf { transition-duration: 320ms; transform: rotateY(38deg); }
}
/* the door's own shadow on the page: tight and dark when it stands, wide and faint while it is still in the air */
.door::after { content: ""; position: absolute; z-index: -1; left: 4%; right: 4%; bottom: -16px; height: 30px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(90, 42, 0, .26), rgba(90, 42, 0, 0)); }

.doors__connect { margin: clamp(44px, 5vw, 72px) auto 0; width: fit-content; max-width: min(100%, 50rem); display: flex; align-items: center; gap: 14px;
  padding: 14px 22px 14px 16px; border-radius: .7em .85em .75em .6em / .78em .6em .85em .7em; rotate: -.5deg;
  background: var(--lemon); color: var(--ink); font: 700 var(--t-body)/1.45 var(--font-body);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 1px rgba(90, 42, 0, .22), 0 10px 18px -12px rgba(90, 42, 0, .45); }
.doors__connect img { width: 40px; height: 40px; flex: none; }

/* ---------- narrower: three narrow doors, then one door each in a column */
@media (max-width: 1099.98px) {
  .doors__row { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 820px; margin-inline: auto; gap: 30px; }
  .door { --arch: clamp(110px, 18vw, 180px); }
  .door__window { aspect-ratio: 1 / .78; }
  .door__panel { padding: 20px 34px 0 12px; }
  .door__name { font-size: clamp(25px, 3.4vw, 31px); }
}
@media (max-width: 639.98px) {
  .doors__row { grid-template-columns: minmax(0, 1fr); max-width: 520px; gap: 30px; }
  .door { --arch: clamp(120px, 38vw, 210px); }
  .door__window { aspect-ratio: 1 / .72; }
  .doors__connect { align-items: flex-start; }
}
@media (max-width: 479.98px) {
  .door__window { aspect-ratio: 1 / .8; }
  .door__name { font-size: 27px; }
}

/* ---------- entrances: the doors are set down on twos */
@media (prefers-reduced-motion: no-preference) {
  html.js:not(.rm) .doors [data-b].b-wait:not(.b-in) { opacity: 0; }
  .doors [data-b="door"].b-in { animation: door-in 580ms steps(1, end) var(--b-at, 0ms) both; }
  .doors [data-b="door"].b-wait:not(.b-in)::after { opacity: 0; }
  .doors [data-b="door"].b-in::after { animation: door-shadow 580ms steps(1, end) var(--b-at, 0ms) both; }
}
/* the shadow stays on the page while the door drops onto it (it mirrors door-in's height), then tightens */
@keyframes door-shadow {
  0% { opacity: .3; transform: translateY(30px) scale(1.3, 1.5); }
  14.3% { opacity: .5; transform: translateY(17px) scale(1.18, 1.3); }
  28.6% { opacity: .75; transform: translateY(7px) scale(1.08, 1.14); }
  42.9% { opacity: .92; transform: translateY(1.5px) scale(1.02, 1.04); }
  57.1%, 100% { opacity: 1; transform: none; }
}
@keyframes door-in {
  0% { opacity: 0; transform: translateY(-30px) rotate(-2.4deg) scale(1.03); }
  14.3% { opacity: 1; transform: translateY(-17px) rotate(-1.4deg) scale(1.018); }
  28.6% { transform: translateY(-7px) rotate(-.6deg) scale(1.007); }
  42.9% { transform: translateY(-1.5px) rotate(-.15deg); }
  57.1%, 100% { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .door__leaf, .door__go::after { transition: none; }
  .doors [data-b] { animation: none !important; opacity: 1 !important; }
}
@media (prefers-contrast: more) {
  .door__leaf { box-shadow: inset 0 0 0 3px var(--ink); }
}
@media (forced-colors: active) {
  .door__leaf { border: 2px solid CanvasText; }
  .door__way { display: none; }
}

/* R6 (9 Nov): five doors (Kuru Sings joins), felt mascots in the windows, names that fit one line */
.doors__row { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(14px, 1.6vw, 24px); }
.door__name { font-size: clamp(20px, 1.55vw, 24px); }
.door__for { font-size: 15px; } .door__line { font-size: 16px; }
.door--sings { --door-c: var(--mint); --door-tex: url(/assets/art/textures/grain-soft-tile.webp); --door-tex-size: 256px 256px; --door-blend: multiply;
  --door-fg: var(--ink); --door-fg-2: #1F6B3A; --door-sky: #EAF3FF; --door-ground: transparent; --door-tilt: .6deg; }
.door--sings .door__window::before, .door--games .door__window::before { display: none; }
.door__sun { width: 54%; top: 6%; rotate: 0deg; }
.door__nila { left: 26%; top: 4%; width: 50%; rotate: 0deg; }
.door__kuru--games, .door__kuru--sings { left: 50%; bottom: 0; width: 60%; translate: -50% 0; z-index: 3; }
.door--games .door__maze { left: 6%; top: 10%; width: 30%; opacity: .9; }
.door--games .door__cards { right: 4%; top: 10%; width: 34%; }
.door--games .door__piece { left: 6%; bottom: 8%; width: 20%; }
.door__note { width: 11%; height: auto; filter: drop-shadow(0 4px 4px rgba(30, 42, 90, .2)); }
.door__note--a { left: 12%; top: 14%; rotate: -14deg; }
.door__note--b { right: 10%; top: 24%; width: 8%; rotate: 12deg; }
.door__star--c { right: 20%; top: 10%; width: 9%; }
@media (max-width: 1099.98px) {
  .doors__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doors__row > .door:nth-child(5) { grid-column: 1 / -1; width: 100%; max-width: 395px; justify-self: center; }
}
@media (max-width: 639.98px) { .doors__row { grid-template-columns: minmax(0, 1fr); } .doors__row > .door:nth-child(5) { grid-column: auto; max-width: none; } }
