/* ============================================================
   Carrier Gate Kiosk — Stylesheet
   Road-sign layout on a warehouse-yard palette: green (in) and
   blue (out) sign panels on concrete, Overpass type.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Overpass, self-hosted (SIL OFL 1.1 — see assets/fonts/OFL.txt).
   Variable font: one file per subset covers weights 400–800. */
@font-face {
  font-family: 'Overpass';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/overpass-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Overpass';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/overpass-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Palette — "warehouse yard": concrete, asphalt-dark ink, road-sign
     green/blue for the two directions, marking yellow, stop red. */
  --concrete:    #E9EBE6;   /* page background            */
  --white:       #FFFFFF;   /* paper, inputs              */
  --ink:         #1D2427;   /* text, edges, header        */
  --ink-soft:    #4B555B;   /* secondary text             */
  --line:        #B8BFBA;   /* rules, dividers            */
  --line-soft:   #D7DCD8;   /* tracks, faint dividers     */
  --go:          #0B7A4B;   /* check-in  (green)          */
  --out:         #1F55A6;   /* check-out (blue)           */
  --amber:       #F2B400;   /* markings, "early" warning  */
  --amber-wash:  #FCEBB0;   /* warning notice background  */
  --red:         #B8232B;   /* errors, "late"             */

  --bg:          var(--concrete);
  --text:        var(--ink);
  --text-muted:  var(--ink-soft);
  --rule:        var(--line);
  --focus:       var(--ink);

  /* White controls need an outline to stand out from the concrete
     background; coloured ones don't (green 4.5:1, blue 6:1). */
  --outline:     var(--ink-soft);   /* 6.4:1 on concrete */

  /* Flow colour — swapped by body[data-flow] */
  --flow:      var(--go);
  --flow-ink:  var(--white);

  /* Type */
  --font: 'Overpass', 'Segoe UI', system-ui, sans-serif;
  --fs-sm:   0.82rem;   /* ~18px */
  --fs-base: 1rem;      /* 22px  */
  --fs-md:   1.27rem;   /* ~28px */
  --fs-lg:   1.64rem;   /* ~36px */
  --fs-xl:   2.18rem;   /* ~48px */
  --fs-xxl:  clamp(2.6rem, 6vw, 4.4rem);

  /* Shape */
  --sign-radius: 22px;
  --sign-inset:  10px;
  --sign-border: 6px;
  --tap: 88px;
  --gutter: clamp(16px, 3vw, 48px);
}

body[data-flow="checkout"] {
  --flow:     var(--out);
  --flow-ink: var(--white);
}

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font);
  font-size: 22px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

:focus-visible {
  outline: 5px solid var(--focus);
  outline-offset: 8px;
}

.num { font-variant-numeric: tabular-nums lining-nums; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Layout ───────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
}

.kiosk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 var(--gutter);
  min-height: 76px;
  background: var(--ink);
  color: var(--white);
  border-bottom: 4px solid var(--amber);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
}

.brand-logo {
  display: block;
  height: 48px;
  width: auto;
  flex-shrink: 0;
}

/* Thin marking-yellow rule between logo and location */
.brand .site-name {
  padding-left: 20px;
  border-left: 2px solid var(--amber);
}

.site-name {
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.2;
}

.header-clock {
  font-size: var(--fs-md);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.screen {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(20px, 3.5vh, 48px) var(--gutter);
}
.screen.active { display: flex; flex-direction: column; }

/* ── Sign panel (shared) ──────────────────────────────────── */
.sign {
  --panel:      var(--flow);
  --panel-ink:  var(--flow-ink);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  background: var(--panel);
  color: var(--panel-ink);
  border-radius: var(--sign-radius);
  /* Border line inset from the panel edge, in the panel's ink colour */
  box-shadow:
    inset 0 0 0 var(--sign-inset) var(--panel),
    inset 0 0 0 calc(var(--sign-inset) + var(--sign-border)) var(--panel-ink);
  padding: calc(var(--sign-inset) + var(--sign-border) + clamp(20px, 3vw, 44px));
}

.sign-title {
  font-size: var(--fs-xxl);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
}

.sign-sub {
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.2;
  margin-top: 0.5em;
}

/* ── ① Home ───────────────────────────────────────────────── */
#screen-home { gap: clamp(20px, 3vh, 40px); }

.gantry {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(24px, 4vw, 72px);
  min-height: 0;
  position: relative;
}

/* Lane line between the two signs */
.gantry::before {
  content: '';
  position: absolute;
  top: 8%; bottom: 8%;
  left: 50%;
  border-left: 6px dashed var(--amber);
  transform: translateX(-50%);
}

.gantry .sign {
  justify-content: flex-end;
  min-height: 300px;
  transition: transform 0.1s ease, filter 0.1s ease;
}
.gantry .sign:active { transform: scale(0.985); filter: brightness(0.92); }

.sign-checkin  { --panel: var(--go);     --panel-ink: var(--white); }
.sign-checkout { --panel: var(--out); --panel-ink: var(--white); }

.sign-arrow {
  width: clamp(64px, 9vw, 120px);
  height: auto;
  fill: currentColor;
  margin-bottom: auto;
}
.sign-arrow-exit { transform: rotate(45deg); transform-origin: 50% 60%; }

.home-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
}

.home-hint {
  font-size: var(--fs-md);
  color: var(--text-muted);
  max-width: 34em;
}

.home-lang { display: flex; gap: 12px; }

.lang-btn {
  min-height: 64px;
  padding: 0 22px;
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  border: 3px solid var(--outline);
  font-size: var(--fs-sm);
  font-weight: 800;
  transition: transform 0.1s ease, filter 0.1s ease;
}
.lang-btn:active { transform: scale(0.97); }
.lang-btn.active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
}

/* ── Step screens ─────────────────────────────────────────── */
.step-screen {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 4vh, 48px);
}

/* Route: flow plate + three-stop progress */
.route {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 28px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 4px 20px 0;
  border-radius: 10px;
  background: var(--go);
  color: var(--white);
  box-shadow: inset 0 0 0 4px var(--go), inset 0 0 0 7px var(--white);
  font-size: var(--fs-base);
  font-weight: 800;
}
.step-badge.checkout {
  background: var(--out);
  color: var(--white);
  box-shadow: inset 0 0 0 4px var(--out), inset 0 0 0 7px var(--white);
}

.route-steps {
  list-style: none;
  counter-reset: stop;
  display: flex;
  align-items: center;
  gap: 12px;
}

.route-steps li {
  counter-increment: stop;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.route-steps li::before {
  content: counter(stop);
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  padding-top: 3px;
  border-radius: 50%;
  border: 3px solid var(--line);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Dashed road segment leading into each later stop */
.route-steps li + li {
  padding-left: 46px;
  background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 13px)
              0 50% / 34px 3px no-repeat;
}

.route-steps li[aria-current="step"] { color: var(--text); }
.route-steps li[aria-current="step"]::before {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

.step-title {
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.1;
}

.step-hint {
  font-size: var(--fs-md);
  color: var(--text-muted);
  margin-top: 0.4em;
}

/* ── ② Load ID ────────────────────────────────────────────── */
.loadid-body {
  width: 100%;
  max-width: 880px;
  display: flex;
  flex-direction: column;
}

.load-input {
  width: 100%;
  margin-top: clamp(20px, 4vh, 40px);
  height: clamp(96px, 14vh, 132px);
  padding: 8px 32px 0;
  background: var(--white);
  color: var(--ink);
  border: 0;
  border-radius: 16px;
  box-shadow: inset 0 0 0 4px var(--white), inset 0 0 0 8px var(--ink);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  user-select: text;
  caret-color: var(--go);
}
.load-input:focus { outline: 5px solid var(--flow); outline-offset: 5px; }
.load-input:disabled { opacity: 0.6; }

.field-error {
  display: none;
  margin-top: 16px;
  padding: 14px 20px 12px;
  border-left: 8px solid var(--red);
  background: var(--white);
  color: var(--red);
  font-size: var(--fs-base);
  font-weight: 800;
  border-radius: 0 8px 8px 0;
}

.loadid-body .btn-row { margin-top: clamp(24px, 5vh, 48px); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 16px;
  width: 100%;
}

.btn {
  min-height: var(--tap);
  padding: 6px 36px 0;
  border-radius: 14px;
  font-size: var(--fs-md);
  font-weight: 800;
  line-height: 1.1;
  transition: transform 0.1s ease, filter 0.1s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); filter: brightness(0.92); }
.btn:disabled { opacity: 0.55; cursor: progress; }

.btn-go {
  flex: 1;
  background: var(--flow);
  color: var(--flow-ink);
  box-shadow:
    inset 0 0 0 6px var(--flow),
    inset 0 0 0 9px var(--flow-ink);
}

.btn-ghost {
  border: 3px solid var(--outline);
  background: var(--white);
  color: var(--ink);
}

/* ── ③ Confirm ────────────────────────────────────────────── */
.confirm-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(24px, 3vw, 48px);
  align-items: start;
}

/* Bill-of-lading paper */
.paper {
  background: var(--white);
  color: var(--ink);
  border-radius: 6px;
  padding: clamp(24px, 3vw, 40px);
  border: 2px solid var(--line);
  border-top: 14px solid var(--flow);
}

.paper-title {
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1.15;
}

.paper-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.2;
}

.paper-load {
  margin-top: 20px;
  padding-bottom: 20px;
  border-bottom: 3px solid var(--ink);
}

.paper-load-id {
  display: block;
  font-size: clamp(2.6rem, 5vw, 3.8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}

.paper-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.paper-field {
  padding: 14px 16px 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.paper-field-wide { grid-column: 1 / -1; }
.paper-grid .paper-field:nth-last-child(-n+2) { border-bottom: 0; }

.paper-value {
  font-size: var(--fs-base);
  font-weight: 600;
  margin-top: 2px;
  word-break: break-word;
}
.paper-field-wide .paper-value { font-size: var(--fs-md); font-weight: 800; }

.confirm-side {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.note-label {
  display: block;
  font-size: var(--fs-base);
  font-weight: 600;
  margin-bottom: 10px;
}
.note-optional { color: var(--text-muted); font-weight: 400; }

.comment-input {
  width: 100%;
  min-height: 120px;
  padding: 16px 20px;
  resize: none;
  background: var(--white);
  color: var(--ink);
  border: 3px solid var(--line);
  border-radius: 12px;
  font-size: var(--fs-base);
  user-select: text;
}
.comment-input:focus { outline: 5px solid var(--focus); outline-offset: 2px; border-color: var(--ink); }

.confirm-side .field-error { margin-top: 0; }

/* ── Timing signs ─────────────────────────────────────────── */
.timing-section { display: flex; flex-direction: column; gap: 14px; }

.timing-sign {
  display: flex;
  align-items: center;
  gap: 20px;
}

.timing-text { display: flex; flex-direction: column; }
.timing-text strong {
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1.1;
}
.timing-text span {
  font-size: var(--fs-base);
  color: var(--text-muted);
}

/* Diamond warning sign — rotated square with inset border */
.diamond {
  --d-bg: var(--amber);
  --d-fg: var(--ink);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 64px; height: 64px;
  margin: 13px;
  background: var(--d-bg);
  border-radius: 8px;
  transform: rotate(45deg);
  box-shadow: inset 0 0 0 4px var(--d-bg), inset 0 0 0 7px var(--d-fg);
}
.diamond > * {
  transform: rotate(-45deg);
  color: var(--d-fg);
  font-weight: 800;
  font-size: var(--fs-lg);
  line-height: 1;
  padding-top: 4px;
}

.timing-sign.late .diamond { --d-bg: var(--red); --d-fg: var(--white); }

/* On time: a small rectangular plate instead of a warning */
.timing-plate {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 90px; height: 64px;
  background: var(--go);
  border-radius: 10px;
  box-shadow: inset 0 0 0 4px var(--go), inset 0 0 0 7px var(--white);
}
.timing-plate svg { width: 36px; height: 36px; fill: none; stroke: var(--white); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }

.timing-extreme {
  display: none;
  padding: 16px 20px 14px;
  background: var(--amber-wash);
  color: var(--ink);
  border-left: 8px solid var(--amber);
  border-radius: 0 10px 10px 0;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.35;
}

/* ── ④ Success ────────────────────────────────────────────── */
.success-wrap {
  width: 100%;
  max-width: 1100px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 4vh, 44px);
}

.success-sign { width: 100%; }

.success-check {
  width: clamp(64px, 8vw, 100px);
  height: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 20px;
}

.success-detail {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-top: 0.4em;
}
.success-detail strong { font-weight: 800; letter-spacing: 0.05em; }

.success-meta {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 24px;
}
.success-meta-item {
  border-top: 4px solid var(--line);
  padding-top: 12px;
}
.success-meta-label {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: 600;
}
.success-meta-value {
  font-size: var(--fs-md);
  font-weight: 800;
  line-height: 1.2;
}

.success-foot {
  display: flex;
  align-items: center;
  gap: 32px;
}
.countdown { flex: 1; }
.countdown-bar {
  height: 10px;
  background: var(--line-soft);
  border-radius: 5px;
  overflow: hidden;
}
.countdown-fill {
  height: 100%;
  width: 100%;
  background: var(--ink);
  transition: width 1s linear;
}
.countdown-label {
  margin-top: 10px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Inactivity overlay ───────────────────────────────────── */
#inactivity-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: var(--gutter);
  text-align: center;
  background: rgba(29, 36, 39, 0.96);   /* --ink */
  color: var(--white);
  cursor: pointer;
}
#inactivity-overlay.visible { display: flex; }

.overlay-diamond {
  width: 180px; height: 180px;
  margin: 50px;
  border-radius: 18px;
  box-shadow: inset 0 0 0 8px var(--amber), inset 0 0 0 14px var(--ink);
}
.overlay-diamond .overlay-count {
  font-size: 5rem;
  font-variant-numeric: tabular-nums;
  padding-top: 12px;
}

.overlay-title {
  font-size: var(--fs-xl);
  font-weight: 800;
  line-height: 1.1;
}
.overlay-text {
  font-size: var(--fs-md);
  color: var(--line);
  max-width: 24em;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1000px) {
  .confirm-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px), (orientation: portrait) {
  .gantry { grid-template-columns: 1fr; }
  .gantry::before { display: none; }
  .gantry .sign { min-height: 220px; }
}

@media (max-width: 600px) {
  html, body { font-size: 18px; }
  :root { --sign-radius: 16px; --sign-inset: 7px; --sign-border: 4px; --tap: 72px; }
  .kiosk-header { min-height: 60px; }
  .brand { gap: 12px; }
  .brand-logo { height: 36px; }
  .brand .site-name { padding-left: 12px; font-size: var(--fs-sm); }
  .home-lang { width: 100%; }
  .lang-btn { flex: 1; padding: 0 8px; }
  .route-steps li + li { padding-left: 30px; background-size: 22px 3px; }
  .route-steps li::before { width: 30px; height: 30px; }
  .btn { padding: 6px 20px 0; }
  .paper-grid { grid-template-columns: 1fr; }
  .paper-grid .paper-field:nth-last-child(2) { border-bottom: 1px solid var(--line-soft); }
  .success-meta { grid-template-columns: 1fr; gap: 12px; }
  .success-foot { flex-direction: column; align-items: stretch; gap: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
