/*
 * box.css - scene 2: the open recipe box, its divider tabs, the riffling deck, and
 * the layer where one card is held up.
 *
 * Talks to: js/box.js builds the elements styled here. card.css styles the cards.
 *
 * Say it to a judge: "Cards in the box are stacked on top of each other and
 * JavaScript slides each one up by a strip, so you see a ladder of titles. The
 * forward tilt as a card is flicked past is a 3D CSS transform."
 */

.box-bg {
  position: absolute;
  inset: 0;
  height: 100%;
}

/* Everything that blurs when a card is held up. */
.box-stage {
  position: absolute;
  inset: 0;
  transition: filter 0.5s ease;
}
.has-focus .box-stage { filter: blur(calc(var(--u) * 0.35)) brightness(0.6); }
/* WHY: fading a blur in is the costly part on a tablet, so touch devices switch it
   on in one step (the card's own lift animation hides the jump). */
@media (hover: none) {
  .box-stage { transition: none; }
}

/* The box. Everything inside it is placed in percentages of the box picture
   (obj-box-body-open.png), so the cards stay in the box whatever size it is drawn. */
.box {
  position: absolute;
  left: 27%;
  top: 25%;
  width: 50%;
  aspect-ratio: 711 / 630;
  perspective: calc(var(--u) * 120);
}
.box-back,
.box-front {
  position: absolute;
  inset: 0;
}
/* The front copy shows only the near walls: everything below the line that runs
   along the box's left rim and front rim. Cards behind it look like they're inside. */
.box-front {
  -webkit-clip-path: polygon(0 13%, 5% 13%, 34.5% 42%, 98.5% 26.5%, 100% 26.5%, 100% 100%, 0 100%);
  clip-path: polygon(0 13%, 5% 13%, 34.5% 42%, 98.5% 26.5%, 100% 26.5%, 100% 100%, 0 100%);
  pointer-events: none;
}
/* The open lid stands up from the box's back rim. box.js leans it to match the box. */
.box-lid {
  position: absolute;
  left: 5.5%;
  bottom: 85%;
  width: 63%;
  transform-origin: left bottom;
}
.box-brass-label {
  position: absolute;
  left: 58.5%;
  top: 62.5%;
  width: 19%;
  transform: rotate(-12deg);
  font-family: var(--font-typed);
  font-size: calc(var(--u) * 0.72);
  line-height: 1.05;
  text-align: center;
  color: var(--walnut-dark);
  pointer-events: none;
}

/* ---------- The tab rail ---------- */
.tab-rail {
  position: absolute;
  left: 4%;
  top: 6%;
  width: 21%;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.5);
}

.rail-tab {
  min-height: calc(var(--u) * 3.9);    /* about 46px on an iPad: comfortable to tap */
  padding: 0.1em 0.8em;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: calc(var(--u) * 1.7);
  text-align: left;
  color: var(--ink);
  background: #c9a876;                 /* kraft paper */
  border-radius: calc(var(--u) * 0.6) calc(var(--u) * 0.6) calc(var(--u) * 0.15) calc(var(--u) * 0.15);
  box-shadow: 0 calc(var(--u) * 0.15) calc(var(--u) * 0.3) rgba(23, 17, 13, 0.4);
  transition: filter 0.4s ease;
}
.rail-tab:hover,
.rail-remove:hover { filter: brightness(1.08); }
/* A divider's tab with the small x that takes it out of the box. */
.rail-row {
  display: flex;
  gap: calc(var(--u) * 0.35);
}
.rail-row .rail-tab { flex: 1; min-width: 0; }
.rail-remove {
  flex: none;
  width: calc(var(--u) * 3.9);          /* square, and as tall as the tab: easy to tap */
  font-family: var(--font-hand);
  font-size: calc(var(--u) * 2);
  line-height: 1;
  color: var(--walnut);
  background: #c9a876;
  border-radius: calc(var(--u) * 0.6) calc(var(--u) * 0.6) calc(var(--u) * 0.15) calc(var(--u) * 0.15);
  box-shadow: 0 calc(var(--u) * 0.15) calc(var(--u) * 0.3) rgba(23, 17, 13, 0.4);
  opacity: 0.75;
  transition: filter 0.4s ease, opacity 0.4s ease;
}
.rail-remove:hover,
.rail-remove:focus-visible { opacity: 1; }
.rail-tab-new { color: var(--walnut); font-weight: 400; }
.rail-tab-input { border: 0; width: 100%; }

/* ---------- The deck ---------- */
/* .deck is the front card's place: its feet are down inside the box and box.js
   leans it to the angle of the box's front edge. */
.deck {
  position: absolute;
  left: 37.5%;
  top: 12.5%;
  width: 56%;
  aspect-ratio: 5 / 3;
  transform-origin: left bottom;
  /* WHY: we handle finger drags ourselves; without this the browser would also
     try to scroll or zoom the page with the same gesture. */
  touch-action: none;
}

.deck-item {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  transform-origin: bottom center;
}

.deck-card {
  text-align: left;
  color: var(--ink);
  border-radius: calc(var(--u) * 0.25);
  box-shadow: 0 calc(var(--u) * -0.08) calc(var(--u) * 0.3) rgba(23, 17, 13, 0.3);
  background:
    linear-gradient(to bottom, transparent 15.5%, rgba(181, 82, 74, 0.55) 15.5% 16.3%, transparent 16.3%),
    var(--paper);
}
.deck-title {
  position: absolute;
  left: 4%;
  right: 4%;
  top: 0;
  height: 9.5%;                         /* the strip that stays visible */
  display: flex;
  align-items: center;
  font-size: calc(var(--u) * 1.12 * var(--font-scale, 1));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cards yellow as they age, even as strips in the deck. */
.deck-card.stage-1 { background-color: #f6ecd0; }
.deck-card.stage-2 { background-color: #f0e2bd; }
.deck-card.stage-3 { background-color: #e8d5a6; border-radius: calc(var(--u) * 0.6); }

/* A divider is the kraft card with a tab from divider-tab.png. The tab takes up the
   divider's own title strip, so it never covers the title of the card behind it. */
.deck-divider > .asset {
  position: absolute;
  inset: 0;
  height: 100%;
  aspect-ratio: auto !important;
  filter: drop-shadow(0 calc(var(--u) * -0.08) calc(var(--u) * 0.15) rgba(23, 17, 13, 0.3));
}
.deck-divider > .asset img { object-fit: fill; }
.deck-divider > .asset.is-placeholder { background: #c9a876; border: 0; }
.deck-divider > .asset .asset-label { display: none; }
.deck-tab {
  position: absolute;
  left: 34%;
  width: 32%;
  top: 0.5%;
  height: 9.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: calc(var(--u) * 0.95);
  white-space: nowrap;
  overflow: hidden;
  color: var(--ink);
}

/* ---------- A card held up ---------- */
.focus-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;                 /* empty space lets nothing through... */
}
.focus-layer > * { pointer-events: auto; }  /* ...but the card and marks work */

.focus-holder {
  display: flex;
  align-items: stretch;
  --card-w: 56;
  filter: drop-shadow(0 calc(var(--u) * 0.8) calc(var(--u) * 1.5) rgba(23, 17, 13, 0.55));
}

/* The pencil marks: a strip of the same paper along the card's right edge. */
.pencil-marks {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: calc(var(--u) * 0.2);
  width: calc(var(--u) * 13);
  padding: calc(var(--u) * 0.8);
  background: var(--paper);
  border-left: calc(var(--u) * 0.12) dashed var(--pencil);
  border-radius: 0 calc(var(--u) * 0.4) calc(var(--u) * 0.4) 0;
}

.pencil-mark {
  display: flex;
  align-items: center;
  gap: 0.4em;
  min-height: calc(var(--u) * 3.8);    /* about 45px on an iPad */
  padding: 0 0.4em;
  font-family: var(--font-hand);
  font-size: calc(var(--u) * 1.7);
  text-align: left;
  color: var(--pencil);
  border-bottom: calc(var(--u) * 0.1) solid transparent;
  transition: color 0.3s ease, border-color 0.3s ease;
}
.pencil-mark:hover { color: var(--ink); border-bottom-color: var(--pencil); }
.pencil-mark:focus-visible { outline-color: var(--burnt-orange); }
.pencil-mark.mark-cook { color: var(--burnt-orange); font-weight: 700; }
.pencil-mark.has-icon .asset { width: 1.5em; flex: none; }
.pencil-mark.has-icon .asset-label { display: none; }

/* ---------- Slips: "Throw this card out?" and "Move to..." ---------- */
.slip {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.2);
  min-width: calc(var(--u) * 24);
  max-width: calc(var(--u) * 34);
  max-height: 86%;
  overflow-y: auto;
  padding: calc(var(--u) * 1.4) calc(var(--u) * 2);
  transform: rotate(-1.5deg);
  background: var(--cream);
  border-radius: calc(var(--u) * 0.3);
  box-shadow: 0 calc(var(--u) * 0.5) calc(var(--u) * 1.5) rgba(23, 17, 13, 0.6);
}
.slip-question {
  margin: 0 0 0.3em;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: calc(var(--u) * 2.2);
  color: var(--ink);
}

/* ---------- The X in the top-right corner ---------- */
.scene-close {
  position: absolute;
  top: 3%;
  right: 2.5%;
  width: calc(var(--u) * 4);
  height: calc(var(--u) * 4);
  font-family: var(--font-hand);
  font-size: calc(var(--u) * 3.6);
  line-height: 1;
  color: var(--cream);
  /* A dark disc behind it, so the X shows up on light walls as well as dark ones. */
  background: rgba(23, 17, 13, 0.5);
  border-radius: 50%;
}
