/* arrival.css — F4 of /entangle soc-495.
   Garden v3 Arrival Protocol Red Box styling. Reuses the existing
   .timer-bar-rule width-interpolation pattern from index.html:178-187 for
   the countdown rule. No new timer logic — wrap, don't reinvent.

   Variables expected from index.html :root:
     --paper, --ink, --ink-64, --ink-42, --red, --rule.
   If --red is absent, fall back to a load-bearing crimson. */

/* ─── body-level gate ──────────────────────────────────────────────────
   While the Arrival Protocol is running, the standard input UI is
   suppressed. On arrivalState === 'arrived' the body class drops and the
   usual .terminal-input-line / .input-hint / .soil surfaces come back. */
body.body-arriving .soil,
body.body-arriving .input-hint {
  opacity: 0.32;
  pointer-events: none;
}

body.body-arriving .timer-bar {
  /* The /timer bar is the Catch-phase primitive; during Arrival it must
     not steal the red rule from the .red-box below. */
  display: none !important;
}

/* ─── .red-box — the ceremonial container ──────────────────────────────
   Full-width above the input line. Bold red border; red accent text;
   tabular-nums for the countdown so the digits don't shift. EB Garamond
   italic for the ceremonial prompt per Logan's "beautiful PDF" aesthetic
   (SF system body, serif for ceremony). */
.red-box {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  padding: 18px 32px 22px 32px;
  margin: 0;

  font-size: 13px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;

  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.red-box[hidden] { display: none; }

/* The ceremonial prompt — large italic EB Garamond, ink not red so the
   text reads first and the red border frames it. */
.red-box .red-box-prompt {
  font-family: "EB Garamond", "Hoefler Text", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: var(--ink, #1a1a1a);
  text-transform: none;
  white-space: pre-wrap;
}

/* The countdown digits — monospace, tabular, red. */
.red-box .red-box-time {
  align-self: flex-end;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--red, #D0342C);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

/* The shrinking rule — REUSES the .timer-bar-rule visual pattern.
   1px red line pinned to the bottom edge; width animates 100% → 0% over
   the timer duration. The 1s linear transition mirrors .timer-bar-rule
   in index.html:178-186 so the Catch-phase dump and the Arrival Red Box
   speak the same visual language. */
.red-box .red-box-rule {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1px;
  background: var(--red, #D0342C);
  width: 100%;
  transition: width 1s linear, opacity 0.3s ease;
}

.red-box.ending .red-box-rule {
  opacity: 0;
}

/* ─── timing variants ──────────────────────────────────────────────────
   data-timing="30" — step 4 naming window (MAX 30 SEC).
   data-timing="60" — step 5 declaration window (MAX 60 SEC).
   Visual difference is subtle: 60s box uses a thicker border and slightly
   taller padding, reflecting the greater weight of the declaration. */
.red-box[data-timing="30"] {
}

.red-box[data-timing="60"] {
  padding-top: 22px;
  padding-bottom: 26px;
}

.red-box[data-timing="60"] .red-box-prompt {
  font-size: 20px;
}

/* ─── entering animation ───────────────────────────────────────────────
   Reuse the project-wide .entering fade + slide-in shape so the Red Box
   lands the same way garden lines do. If .entering is not defined at the
   project level, this rule is inert. */
.red-box.entering {
  animation: red-box-arrive 220ms ease-out;
}

@keyframes red-box-arrive {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* ─── W1 soc-495: data-active countdown driver ─────────────────────────
   The Red Box DOM driver in arrival-protocol.mjs flips
   [data-active="false"] -> [data-active="true"] after a reflow, while
   also setting the custom property --arrival-timer-duration on the rule
   element. The CSS here carries the transition so the width animation
   matches .timer-bar-rule's 1s-linear cadence visually but is timed to
   the full Red Box window (30s or 60s). No JS rAF loop needed for the
   shrinking bar — the browser interpolates the width. */
.red-box .red-box-rule[data-active="false"] {
  width: 100%;
  transition: none;
}
.red-box .red-box-rule[data-active="true"] {
  width: 0%;
  transition: width var(--arrival-timer-duration, 30s) linear,
              opacity 0.3s ease;
}

/* ─── W1 soc-495: ceremonial italic nuance on the prompt text ──────────
   When the driver fills the prompt, it tags the node with
   .red-box-prompt-text so we can give the plate line slightly more
   weight and an extra hair of tracking — the prompt is the ceremony's
   voice, not a UI label. Inherits italic + serif + ink color from
   .red-box-prompt above. */
.red-box .red-box-prompt.red-box-prompt-text,
.red-box .red-box-prompt-text {
  font-feature-settings: "liga" 1, "dlig" 1, "onum" 1;
  letter-spacing: 0.015em;
  text-wrap: balance;
}

/* ─── W1 soc-495: entering / ending transitions ────────────────────────
   Mirror the small fade-slide of the opening animation on the ending
   pass so the Red Box doesn't snap out of flow when the visitor
   captures a name or the timer expires. */
.red-box.ending {
  animation: red-box-depart 220ms ease-in forwards;
}

@keyframes red-box-depart {
  from { opacity: 1; transform: translateY(0);    }
  to   { opacity: 0; transform: translateY(-4px); }
}

/* ─── print rules ──────────────────────────────────────────────────────
   Ceremony is a runtime gesture, not a page artifact. Hide on print. */
@media print {
  .red-box { display: none !important; }
}
