/* =============================================================================
   COMPONENT: THREE DOORS
   Rendered from js/data/projects.js (categories) by js/components/doors.js.
   Each leaf is a <button> hinged on the left; opening it swings the door and
   then opens that category's portal (js/components/portal.js).
   The hallway floor is css/pages/home.css (.doors__floor).
   ============================================================================= */
.door {
  --door: var(--tone);
  --portal: var(--tone-tint);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---- Caption above each door (readable without opening anything) ------ */
.door__caption {
  width: min(100%, 300px);
  min-height: 5.4em;
  margin-bottom: 18px;
  text-align: center;
  color: var(--c-cream);
}

.door__caption .meta { justify-content: center; color: var(--c-butter); }

.door__caption p:last-child {
  margin-top: 6px;
  font-size: var(--t-sm);
  line-height: 1.5;
  color: #e8dbbd;
}

/* ---- Frame (architrave) ------------------------------------------------ */
.door__frame {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 5 / 8;
  padding: 12px 12px 0;
  background: #3b342d;
  border: var(--b) solid var(--c-ink);
  border-bottom: 0;
  border-radius: 150px 150px 0 0 / 70px 70px 0 0;
  box-shadow: var(--sh-lg);
}

.door__opening {
  position: relative;
  height: 100%;
  border: var(--b) solid var(--c-ink);
  border-bottom: 0;
  border-radius: 130px 130px 0 0 / 58px 58px 0 0;
  /* perspective only reaches direct children: the leaf lives here */
  perspective: 900px;
  perspective-origin: 50% 45%;
}

/* ---- Portal: the lit room behind the leaf (decorative) ---------------- */
.door__portal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 18px 16px;
  border-radius: inherit;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 30%, #fff7d6 0 30%, transparent 70%),
    repeating-conic-gradient(from 0deg at 50% 30%, rgb(255 255 255 / 0.35) 0 6deg, transparent 6deg 16deg),
    var(--portal);
  text-align: center;
}

.door__num {
  align-self: center;
  padding: 2px 8px;
  background: var(--c-ink);
  color: var(--c-paper);
  font: 700 0.7rem/1.3 var(--f-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.door__title {
  font: 400 clamp(1.6rem, 1.3rem + 0.9vw, 2.1rem)/1 var(--f-heading);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.door__rhyme { font: 700 0.95rem/1.35 var(--f-accent); }

/* ---- Leaf (the actual door) ------------------------------------------- */
.door__leaf {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgb(0 0 0 / 0.12), transparent 18%, transparent 82%, rgb(0 0 0 / 0.1)),
    var(--door);
  border: var(--b) solid var(--c-ink);
  border-bottom: 0;
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform 1.1s var(--e-swing);
  will-change: transform;
}

.door__panel {
  position: absolute;
  left: 15%;
  right: 15%;
  border: var(--b) solid var(--c-ink);
  background: rgb(255 255 255 / 0.22);
  box-shadow: inset 4px 4px 0 rgb(0 0 0 / 0.12);
}

.door__panel--top    { top: 24%; height: 28%; border-radius: 60px 60px 6px 6px / 28px 28px 6px 6px; }
.door__panel--bottom { top: 57%; bottom: 21%; border-radius: 6px; }

.door__panel { overflow: hidden; background: var(--c-cream); }
.door__preview {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 4px;
  background: linear-gradient(145deg, #fff9ed, var(--door));
  font: 700 clamp(0.75rem, 1vw, 0.9rem)/1.2 var(--f-body);
  filter: blur(2px);
  transition: filter 220ms ease;
}
.door__leaf:focus-visible .door__preview { filter: none; }
@media (hover: hover) { .door__leaf:hover .door__preview { filter: none; } }
@media (hover: none) { .door__preview { filter: none; } }

/* Hanging sign */
.door__sign {
  position: absolute;
  top: 9%;
  left: 50%;
  translate: -50% 0;
  padding: 5px 12px 3px;
  background: var(--c-paper);
  border: var(--b-thin) solid var(--c-ink);
  border-radius: 4px;
  box-shadow: var(--sh-sm);
  font: 400 clamp(1.05rem, 0.9rem + 0.5vw, 1.3rem)/1 var(--f-heading);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  rotate: -3deg;
  transform-origin: top center;
}

.door__knob {
  position: absolute;
  right: 9%;
  top: 53%;
  width: 20px;
  height: 20px;
  border: var(--b-thin) solid var(--c-ink);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff4c4, #e0a92a 60%);
  box-shadow: 2px 2px 0 var(--c-ink);
}

/* Chalk note at the foot of the door: Devanagari in the handwritten face */
.door__hint {
  position: absolute;
  left: 50%;
  bottom: 4.5%;
  width: 86%;
  translate: -50% 0;
  font: 700 clamp(0.82rem, 0.75rem + 0.25vw, 0.95rem)/1.3 var(--f-accent);
  text-align: center;
  opacity: 0.88;
}

/* Hover: the door creaks open a few degrees, light leaks out. */
@media (hover: hover) {
  .door:not(.is-open) .door__leaf:hover { transform: rotateY(-16deg); }
  .door__leaf:hover .door__knob { animation: knob-jiggle 420ms ease-in-out; }
  .door__leaf:hover .door__sign { animation: sign-swing 900ms var(--e-out); }
}

@keyframes knob-jiggle {
  25% { rotate: -35deg; }
  60% { rotate: 20deg; }
}

@keyframes sign-swing {
  20% { rotate: 6deg; }
  45% { rotate: -7deg; }
  70% { rotate: 1deg; }
}

/* Open: swings toward you, overshoots on the spring, rests past edge-on. */
.door.is-open .door__leaf { transform: rotateY(-97deg); }

/* ---- Doormat, contact shadow, light spill ----------------------------- */
.door__mat {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(100%, 250px);
  min-height: 44px;
  margin-top: -2px;
  background: repeating-linear-gradient(90deg, #8a5a33 0 6px, #7a4d2a 6px 12px);
  border: var(--b-thin) solid var(--c-ink);
  border-radius: 0 0 10px 10px;
  color: #ffe9c2;
  font: 700 1rem/1 var(--f-body);
}

/* Soft contact shadow so the door sits on the floor instead of floating */
.door__mat::after {
  content: "";
  position: absolute;
  left: -12%;
  right: -12%;
  top: 70%;
  height: 34px;
  z-index: -1;
  background: radial-gradient(50% 55% at 50% 40%, rgb(0 0 0 / 0.5), transparent 75%);
}

.door__mat::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 150%;
  height: 90px;
  translate: -50% 0;
  background: radial-gradient(50% 50% at 50% 0, rgb(255 229 166 / 0.65), transparent 70%);
  opacity: 0;
  transition: opacity 500ms var(--e-out);
  pointer-events: none;
}

.door.is-open .door__mat::before { opacity: 1; }

/* =============================================================================
   FEATURED DOOR (Product design): comic burst, glow and a "Start here" badge.
   Every loop animates rotate / scale / opacity only, and pauses off screen.
   ============================================================================= */
.door--featured .door__frame::before,
.door--featured .door__frame::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

/* Comic speed lines bursting from behind the arch */
.door--featured .door__frame::before {
  left: 50%;
  top: 40%;
  width: 240%;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg, rgb(255 229 166 / 0.42) 0 4deg, transparent 4deg 13deg);
  -webkit-mask: radial-gradient(closest-side, #000 24%, transparent 74%);
  mask: radial-gradient(closest-side, #000 24%, transparent 74%);
  animation: rays-turn 50s linear infinite;
}

/* Warm glow that breathes around the frame */
.door--featured .door__frame::after {
  inset: -16% -36% -4%;
  background: radial-gradient(closest-side, rgb(255 170 140 / 0.9), rgb(255 229 166 / 0.38) 55%, transparent);
  animation: glow-pulse 2.8s ease-in-out infinite;
}

/* Light seams around the closed leaf */
.door--featured .door__opening { box-shadow: 0 0 0 2px rgb(255 229 166 / 0.55), 0 -6px 0 2px rgb(255 229 166 / 0.18); }

/* Comic "emanata" ticks: the door is buzzing */
.door--featured .door__opening::before {
  content: "";
  position: absolute;
  left: -26%;
  right: -26%;
  top: -16%;
  height: 46%;
  z-index: -1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 180' fill='none' stroke='%23ffe5a6' stroke-width='7' stroke-linecap='round'%3E%3Cpath d='M58 150 22 132M66 108 30 76M98 70 76 30M342 150l36-18M334 108l36-32M302 70l22-40'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  animation: buzz 1.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes buzz { 50% { scale: 1.06; opacity: 0.6; } }

.door--featured .door__mat::before { opacity: 0.55; }

/* "Start here!" starburst */
.door__badge {
  --star: polygon(50% 0%, 58.7% 12%, 71.7% 5%, 74.3% 19.5%, 89.1% 18.8%, 85.1% 33.1%, 98.7% 38.9%, 89% 50%, 98.7% 61.1%, 85.1% 66.9%, 89.1% 81.2%, 74.3% 80.5%, 71.7% 95%, 58.7% 88%, 50% 100%, 41.3% 88%, 28.3% 95%, 25.7% 80.5%, 10.9% 81.2%, 14.9% 66.9%, 1.3% 61.1%, 11% 50%, 1.3% 38.9%, 14.9% 33.1%, 10.9% 18.8%, 25.7% 19.5%, 28.3% 5%, 41.3% 12%);
  --bob-rot: 14deg;
  position: absolute;
  top: -26px;
  right: -30px;
  z-index: 4;
  width: 104px;
  aspect-ratio: 1;
  rotate: 10deg;
  animation: bob 2.4s ease-in-out infinite;
  pointer-events: none;
}

.door__badge::before,
.door__badge::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--c-ink);
  clip-path: var(--star);
}

.door__badge::before { translate: 4px 5px; }   /* hard shadow */

.door__badge b {
  position: absolute;
  inset: 5px;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 18%;
  background: var(--c-mustard);
  clip-path: var(--star);
  font: 400 1.05rem/0.95 var(--f-heading);
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: uppercase;
}

/* No JS: doors are not rendered at all (see the <noscript> in index.html). */
