/* ==============================================================
   TOMORROW'S BOX · page styles
   File: /tomorrows-box/tomorrows-box.css
   Colours, font, buttons and form fields come from site.css.
   The "How it helps" section uses shared styles (site.css, section 13).

   Sections:
     1  Wood and brass colours
     2  The room (intro and layout)
     3  The box drawing, lid and tag
     4  The slip that drops into the slot
     5  Panels, time choices and review
   ============================================================== */


/* --------------------------------------------------------------
   1 · WOOD AND BRASS COLOURS (this page only)
   -------------------------------------------------------------- */
:root {
  --wood: #A87B55;
  --wood-light: #C49A72;
  --wood-dark: #8A6243;
  --wood-deep: #3E2A1D;
  --wood-grain: rgba(62, 42, 29, .22);
  --brass: #C9A55A;
  --glow: #FFE6B0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --wood: #8C6546;
    --wood-light: #A67F5C;
    --wood-dark: #6E4E36;
    --wood-deep: #22160F;
    --wood-grain: rgba(20, 12, 6, .3);
    --brass: #B8964E;
    --glow: #F3CF86;
  }
}


/* --------------------------------------------------------------
   2 · THE ROOM
   -------------------------------------------------------------- */
.boxroom {
  padding-block: clamp(1.5rem, 5vw, 3.5rem) clamp(3rem, 8vw, 5.5rem);
  background: linear-gradient(var(--c-sky-top), color-mix(in srgb, var(--c-bank) 30%, var(--bg)));
}
.boxroom__inner {
  display: grid;
  grid-template-columns: minmax(0, 20rem) minmax(0, 1fr);
  gap: 2rem clamp(2rem, 6vw, 5rem);
  align-items: start;
}
.boxroom__intro {
  position: sticky;
  top: calc(var(--header-h) + 2rem);
}
.boxroom__title {
  margin-bottom: .45em;
  font-size: clamp(2.4rem, 1.6rem + 3vw, 4rem);
  font-weight: var(--weight-light);
  letter-spacing: -.025em;
}
.boxroom__lede {
  margin-bottom: 1rem;
  font-size: var(--step-1);
  font-weight: var(--weight-light);
  line-height: 1.45;
}
.boxroom__note { color: var(--muted); font-size: 1rem; }
.boxroom__note + .boxroom__note { margin-top: .75rem; }
.boxroom__note--warn { color: var(--danger); }

.boxroom__work { max-width: 40rem; }
.boxroom__work:focus { outline: none; }

@media (max-width: 900px) {
  .boxroom__inner { grid-template-columns: 1fr; }
  .boxroom__intro { position: static; }
}


/* --------------------------------------------------------------
   3 · THE BOX
   -------------------------------------------------------------- */
.box-stage {
  position: relative;
  max-width: 27rem;
  margin: 0 auto;
}
.box {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.box__shadow  { fill: rgba(20, 30, 36, .16); }
.box__front   { fill: var(--wood); }
.box__grain   { fill: none; stroke: var(--wood-grain); stroke-width: 1.5; stroke-linecap: round; }
.box__base    { fill: var(--wood-dark); opacity: .6; }
.box__inside  { fill: var(--wood-deep); }
.box__top     { fill: var(--wood-light); }
.box__slot    { fill: var(--wood-deep); }
.box__band    { fill: var(--wood-dark); }
.box__brass   { fill: var(--brass); }
.box__keyhole { fill: var(--wood-deep); }
.box__string  { fill: none; stroke: var(--c-ink); stroke-width: 1; opacity: .5; }

.box__glow {
  fill: var(--glow);
  opacity: 0;
  filter: blur(8px);
  transition: opacity .8s ease .2s;
}
.box__slips rect {
  fill: var(--c-paper);
  stroke: var(--c-paper-shade);
  stroke-width: 1;
}
.box__slips {
  opacity: 0;
  transition: opacity .5s ease .3s;
}

/* The lid lifts and tilts back when the box opens */
.box__lid {
  transform-box: view-box;
  transform-origin: 250px 90px;
  transition: transform .8s cubic-bezier(.34, 1.3, .64, 1);
}
.box.is-open .box__lid { transform: translate(0, -48px) rotate(-7deg); }
.box.is-open .box__glow { opacity: .75; }
.box.is-open.has-worries .box__slips { opacity: 1; }

/* A tiny bump when something drops in */
.box.is-bumping #box-body,
.box.is-bumping .box__lid { animation: box-bump .35s ease; }
@keyframes box-bump {
  40% { transform: translateY(2px); }
}

/* A soft pulse when worry time arrives */
.box.is-ready .box__brass { animation: brass-pulse 2.4s ease-in-out infinite; }
@keyframes brass-pulse {
  50% { fill: var(--glow); }
}

/* The paper tag */
.box-tag {
  position: absolute;
  left: 57%;
  top: 57%;
  max-width: 10.5rem;
  margin: 0;
  padding: .3rem .65rem .3rem 1rem;
  background: var(--c-paper);
  color: var(--c-ink);
  font-size: .8rem;
  line-height: 1.3;
  border-radius: 3px 6px 6px 3px;
  box-shadow: 0 2px 6px rgba(20, 30, 36, .2);
  transform: rotate(-5deg);
  transform-origin: left center;
}
.box-tag::before {                         /* the hole for the string */
  content: "";
  position: absolute;
  left: .35rem;
  top: 50%;
  width: .35rem;
  height: .35rem;
  margin-top: -.175rem;
  border-radius: 50%;
  background: var(--c-paper-shade);
}

.box-status {
  margin-top: .75rem;
  text-align: center;
  color: var(--muted);
}


/* --------------------------------------------------------------
   4 · THE SLIP THAT DROPS INTO THE SLOT
   The lane ends exactly at the slot, so the slip disappears as it
   slides "into" the box.
   -------------------------------------------------------------- */
.box-drop {
  position: absolute;
  inset: 0 0 auto 0;
  height: 38.4%;                /* = the slot's position in the drawing (107.5 / 280) */
  overflow: hidden;
  pointer-events: none;
}
.drop-slip {
  position: absolute;
  left: 50%;
  top: 6%;
  width: 36%;
  padding: .35rem .5rem;
  background: var(--c-paper);
  color: var(--c-ink);
  font-size: .7rem;
  line-height: 1.3;
  border-radius: 2px;
  box-shadow: 0 3px 8px rgba(20, 30, 36, .2);
  transform: translate(-50%, 0);
  transform-origin: center bottom;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}


/* --------------------------------------------------------------
   5 · PANELS, TIME CHOICES AND REVIEW
   -------------------------------------------------------------- */
.panel {
  margin-top: 1.75rem;
  padding: clamp(1.25rem, 4vw, 1.75rem);
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
}
.panel__title {
  margin-bottom: .5rem;
  font-size: var(--step-1);
  font-weight: var(--weight-regular);
}
.panel__title:focus { outline: none; }
.panel__join { margin-top: 1rem; color: var(--muted); }
.panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.25rem;
}
.panel__extras {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.btn--small.is-armed { border-color: var(--danger); color: var(--danger); }
#when-toggle { margin-top: .6rem; }

.field__optional { font-weight: var(--weight-regular); color: var(--muted); }

/* Time choices */
.when {
  margin: 1.25rem 0 0;
  padding: 0;
  border: 0;
}
.when legend {
  padding: 0;
  margin-bottom: .25rem;
  font-weight: var(--weight-strong);
}
.when__hint {
  margin-bottom: .75rem;
  font-size: var(--step--1);
  color: var(--muted);
}
.when__options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: .5rem;
}
.when__option {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 48px;
  padding: .55rem .85rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.when__option input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; margin: 0; }
.when__option:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.when__option:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.when__custom { margin-top: .75rem; }
.when__custom label { display: block; margin-bottom: .35rem; font-size: var(--step--1); font-weight: var(--weight-strong); }
.when__custom input {
  padding: .6rem .8rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.when__error { margin-top: .5rem; font-size: var(--step--1); color: var(--danger); }
.when__error:empty { display: none; }

/* The worry slip during review */
.slip {
  padding: 1.5rem 1.6rem 1.4rem;
  background: var(--c-paper);
  color: var(--c-ink);
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(20, 30, 36, .08), 0 16px 32px -18px rgba(20, 30, 36, .45);
  transform: rotate(-.8deg);
}
.slip__count { font-size: var(--step--1); opacity: .6; }
.slip__text {
  margin: .5rem 0 .75rem;
  font-size: var(--step-1);
  font-weight: var(--weight-light);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.slip__text:focus { outline: none; }
.slip__meta { font-size: var(--step--1); opacity: .6; }
.slip__step {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--c-paper-shade);
  font-size: 1rem;
}

.review__q { margin-top: 1.5rem; }
.review__ask { font-size: var(--step-1); font-weight: var(--weight-light); }

.box-live {
  min-height: 1.65em;
  margin-top: 1rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 480px) {
  .panel__actions .btn { flex: 1 1 100%; }
  .box-tag { left: 55%; font-size: .72rem; max-width: 8.5rem; }
}
