/* Departure board (departures.html): split-flap display built from the tokens in site.css. */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  text-transform: none; /* screen readers get the text as written, not the board's capitals */
}

/* ---------- Header: back link next to the language switch ---------- */
.site-header .header-simple + .language { margin-left: var(--s2); }
.site-header .header-simple li { padding-bottom: 0; }
@media (max-width: 479px) {
  .site-header .header-simple a { min-width: 2.75rem; min-height: 2.75rem; justify-content: center; padding: 0; }
  .site-header .header-simple .back-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
}

/* ---------- Page ---------- */
.departures { background: var(--sign-navy); color: var(--sign-text-secondary); padding-top: var(--s10); padding-bottom: var(--s16); }
@media (min-width: 900px) { .departures { padding-top: var(--s12); padding-bottom: var(--s20); } }
.departures :focus-visible { outline-color: var(--signal-blue); }
.departures ::selection { background: var(--signal-blue); color: var(--sign-navy-deep); }

.board-panel {
  container-type: inline-size;
  background: var(--sign-navy-deep);
  border: 1px solid var(--rule-on-sign);
  border-radius: 10px;
  padding: clamp(.75rem, 2.4vw, 1.75rem);
  box-shadow: 0 1px 0 var(--rule-on-sign) inset;
}
/* The phone layout runs edge to edge so the 29 cells stay as large as possible. */
@media (max-width: 639px) {
  .departures .inner { padding-left: 0; padding-right: 0; }
  .board-panel { border-radius: 0; border-inline: 0; padding: var(--s3) var(--s2); }
  .board-note { padding-left: var(--gutter); padding-right: var(--gutter); }
}

.board-note { margin: var(--s4) 0 0; font-size: .95rem; color: var(--sign-text-secondary); max-width: none; }

/* ---------- Board geometry ----------
   Everything inside .board-frame is sized in em, so one font-size per layout scales the
   whole board. --board-ems is the width of one row in em: cells, cell gaps, column gaps
   and row padding (desktop 44 cells, phone 29 cells), with a little slack for rounding. */
.board-frame {
  --cell-w: .7em;
  --cell-h: 1.1em;
  --cell-gap: .07em;
  --column-gap: .42em;
  --row-pad: .16em;
  --board-ems: 35.7;
  font-family: var(--cond);
  font-weight: 600;
  font-size: 14px;
  font-size: calc(100cqi / var(--board-ems));
  line-height: 1;
  text-transform: uppercase;
  color: var(--sign-text);
}
@media (max-width: 639px) { .board-frame { --board-ems: 23.45; } }

.board-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4);
  padding: 0 var(--row-pad) .5em;
  margin-bottom: .55em;
  border-bottom: 1px solid var(--rule-on-sign);
}
.board-title {
  margin: 0;
  font: 700 max(1.3em, 1.2rem)/1.1 var(--cond);
  letter-spacing: .05em;
  color: var(--sign-text);
  text-wrap: nowrap;
}
.board-title-alt { color: var(--sign-text-secondary); font-weight: 500; }
.board-clock {
  margin: 0; flex: none;
  font: 600 max(1.3em, 1.2rem)/1.1 var(--cond);
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: var(--sign-text);
}

/* Column headings: plain text above each column start, never flipped. */
.board-columns { display: flex; align-items: flex-end; height: .7em; padding-left: var(--row-pad); padding-right: var(--row-pad); margin-bottom: .3em; }
.board-column {
  flex: none;
  width: calc(var(--span) * (var(--cell-w) + var(--cell-gap)) - var(--cell-gap));
  white-space: nowrap; /* GATE is wider than its one cell and may run past it */
}
.board-column + .board-column { margin-left: var(--column-gap); }
.board-column-label { display: block; font-size: .46em; line-height: 1; font-weight: 600; letter-spacing: .1em; color: var(--sign-text-secondary); }
/* The phone layout has no one-cell column, so the labels can keep a legible minimum size. */
@media (max-width: 639px) { .board-column-label { font-size: max(.46em, .66rem); } }

/* Rows: each one is a link to the matching section of the start page. */
.board {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .2em;
  /* Reserves the height of the 12 rows before the script builds them (no layout shift). */
  min-height: calc(12 * (var(--cell-h) + .2em) + 11 * .2em);
}
.board-row {
  position: relative;
  display: flex;
  padding: .1em var(--row-pad);
  border-radius: .14em;
  color: inherit;
  text-decoration: none;
  outline: 2px solid transparent;
  outline-offset: 0;
}
.board-row:hover, .board-row:focus-visible { outline-color: var(--signal-blue); outline-offset: 0; }
@media (prefers-reduced-motion: no-preference) { .board-row { transition: outline-color .15s ease-out; } }

.board-cells { display: flex; gap: var(--cell-gap); }
.flap.is-column-start { margin-left: calc(var(--column-gap) - var(--cell-gap)); }
.flap.is-status { color: var(--sign-text-secondary); }
.board-row.is-ongoing .flap.is-status { color: var(--signal-blue); }

/* ---------- One flap cell ----------
   Two static halves show the current character; the leaf is the moving part.
   Upper half: line box as tall as the cell, so only the top of the glyph is visible.
   Lower half: line box of height 0 on the split line, so only the bottom of the glyph is visible.
   No paint containment: the leaf grows slightly past the cell edges while it turns. */
.flap {
  position: relative;
  flex: none;
  width: var(--cell-w);
  height: var(--cell-h);
  contain: size layout style;
  text-align: center;
  white-space: pre;
}
.flap-top, .flap-bottom {
  position: absolute; left: 0; right: 0;
  height: 50%;
  overflow: hidden;
  background: var(--sign-navy-raised);
}
.flap-top {
  top: 0;
  line-height: var(--cell-h);
  border-radius: .09em .09em 0 0;
}
/* Light falls from above: the lower half sits slightly in shadow. */
.flap-bottom, .flap-leaf.is-lower {
  background: color-mix(in srgb, var(--sign-navy-raised) 84%, var(--sign-navy-deep));
}
.flap-bottom {
  top: 50%;
  line-height: 0;
  border-radius: 0 0 .09em .09em;
}

/* The leaf spans the whole cell and is clipped to one half: the upper half while it shows
   the old character falling towards the viewer, the lower half while the new character
   lands. Its transform origin is the split line. At rest it is hidden and untransformed.
   The script folds it with scaleY, the 2D projection of rotateX, so hundreds of leaves can
   turn at once without one compositor layer per leaf. */
.flap-leaf {
  position: absolute; inset: 0;
  z-index: 2;
  line-height: var(--cell-h);
  border-radius: .09em;
  background: var(--sign-navy-raised);
  transform-origin: 50% 50%;
  visibility: hidden;
}
.flap-leaf.is-upper { visibility: visible; clip-path: inset(0 0 50% 0); }
.flap-leaf.is-lower { visibility: visible; clip-path: inset(50% 0 0 0); }

/* The 1px gap between the two halves of every flap. */
.flap::after {
  content: "";
  position: absolute; left: 0; right: 0; top: calc(50% - .5px);
  height: 1px;
  background: var(--sign-navy-deep);
  z-index: 1;
}

/* ---------- Visitor message board ---------- */
.message-section { background: var(--sign-navy); color: var(--sign-text-secondary); padding-top: 0; padding-bottom: var(--s16); }
.message-title { font-size: 1.15rem; color: var(--sign-text); margin: 0 0 var(--s3); }
.message-form { max-width: 25rem; margin: 0 auto var(--s4); }
.message-label { display: block; margin-bottom: var(--s1); font-size: .95rem; }
.message-controls { display: flex; gap: var(--s2); }
.message-input {
  flex: 1; min-width: 0; min-height: 2.75rem; padding: 0 var(--s2);
  font: 500 1rem var(--sans); color: var(--sign-text);
  background: var(--sign-navy-deep); border: 1px solid var(--rule-on-sign); border-radius: 6px;
}
.message-input::placeholder { color: var(--sign-text-secondary); opacity: 1; } /* browser default grey was 3.8:1 on navy */
.message-submit { flex: none; min-height: 2.75rem; cursor: pointer; }
.message-section :focus-visible { outline: 2px solid var(--signal-blue); outline-offset: 2px; }
.message-panel {
  container-type: inline-size;
  max-width: 25rem; margin: 0 auto;
  background: var(--sign-navy-deep); border: 1px solid var(--rule-on-sign); border-radius: 10px;
  padding: var(--s3);
}
/* 18 cells: 18 * .7em + 17 * .07em + row padding, with slack for rounding. */
.message-frame { --board-ems: 14.4; display: grid; gap: .2em; }
.message-frame .board-cells { padding: .1em var(--row-pad); }
.message-title, .message-section .inner { text-align: center; }
.sound-toggle {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 2.75rem; margin-top: var(--s3); padding: 0 var(--s4);
  font: 600 1rem var(--cond); color: var(--sign-text-secondary); cursor: pointer;
  background: transparent; border: 1px solid var(--rule-on-sign); border-radius: 6px;
}
.sound-toggle:hover { color: var(--sign-text); border-color: var(--sign-text-secondary); }
.sound-toggle[aria-pressed="true"] { color: var(--sign-text); border-color: var(--signal-blue); }
.sound-icon { width: 1.25em; height: 1.25em; flex: none; }
.sound-toggle[aria-pressed="false"] .sound-waves,
.sound-toggle[aria-pressed="false"] .sound-state-on,
.sound-toggle[aria-pressed="true"] .sound-state-off { display: none; }
/* No flaps, no sound: the switch would do nothing. */
@media (prefers-reduced-motion: reduce) { .sound-toggle { display: none; } }
