/* flight2cal: boarding pass. Desktop from 1180px wide; below that the ticket stacks (phone layout). */

/* Fonts are served from here, not from Google Fonts, so the page makes no third-party requests.
   Archivo and IBM Plex Mono: SIL Open Font License, see fonts/*-OFL.txt. */
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(fonts/archivo-latin-ext-wdth-normal.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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  font-stretch: 62% 125%;
  src: url(fonts/archivo-latin-wdth-normal.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;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/ibm-plex-mono-latin-ext-400-normal.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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 400;
  src: url(fonts/ibm-plex-mono-latin-400-normal.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;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/ibm-plex-mono-latin-ext-500-normal.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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url(fonts/ibm-plex-mono-latin-500-normal.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;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(fonts/ibm-plex-mono-latin-ext-600-normal.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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 600;
  src: url(fonts/ibm-plex-mono-latin-600-normal.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 {
  --page: #ECE6DA;
  --ticket: #FBF8F1;
  --ink: #1B2433;
  --muted: #5B6472;
  --rule: #D9D1C1;
  --rule-strong: #B9B0A0;
  --accent: #C2410C;
  --accent-text: #9A3412;
  --accent-ring: rgba(194, 65, 12, 0.14);
  --stub-text: #F3EEE4;
  --stub-muted: #A9B3C2;
  --stub-rule: #2E3A4D;
  --disabled: #3A4558;
  --disabled-text: #C3CAD5;
  --placeholder: #6F747E;
  --sans: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--sans); }
a { color: var(--accent-text); }
a:hover { color: #7C2D12; }
input, button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--placeholder); opacity: 1; }

/* ---- Header ---- */

.top { display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 12px; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.logo-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.logo-mark svg { transform: rotate(90deg); }
.top a { font-size: 14px; font-weight: 600; padding: 12px 0; }
h1 { margin: 0; font-size: 40px; line-height: 1; font-weight: 800; font-stretch: 112%; letter-spacing: -0.02em; }
.intro p { margin: 0; font-size: 15px; color: var(--muted); }

/* ---- Ticket ---- */

.ticket { display: flex; }
.main { display: flex; flex-direction: column; min-width: 0; }

h2, .stub-label, .summary-label, .progress {
  margin: 0; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.code { font-size: 64px; line-height: 0.9; font-weight: 800; font-stretch: 112%; letter-spacing: -0.02em; }
.code.is-empty { color: #CFC6B5; }

/* Numbered fields: done (navy tick), current (orange), to do (outlined number). */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-head { display: flex; align-items: center; gap: 7px; height: 20px; }
.field-head label { font-size: 14px; font-weight: 700; }
.badge {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
}
.badge svg { width: 11px; height: 11px; fill: none; stroke: var(--stub-text); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.is-done .badge, .summary .badge { background: var(--ink); }
.is-current .badge { background: var(--accent); color: #fff; }
.is-todo .badge { border: 1.5px solid var(--rule-strong); color: var(--muted); }
.is-current label { color: var(--accent-text); }

.box { display: flex; align-items: center; gap: 8px; height: 40px; border-bottom: 2px solid var(--rule); }
.is-done .box { border-bottom-color: var(--ink); }
.box:focus-within { border-bottom-color: var(--accent); }
.is-current .box { border: 2px solid var(--accent); border-radius: 8px; background: #fff; padding: 0 10px; }
.is-current .box:focus-within { box-shadow: 0 0 0 4px var(--accent-ring); }
.box input, .box select { flex-grow: 1; width: 100%; min-width: 0; height: 100%; border: 0; padding: 0; background: transparent; outline: none; font-size: 16px; text-overflow: ellipsis; }
.is-done .box input { font-weight: 600; }
/* 16px or more: iOS zooms in on focused inputs with smaller text. */
input[inputmode='numeric'] { font-family: var(--mono); font-size: 16px; }

.search-icon { display: none; flex-shrink: 0; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; }
.is-current .search-icon { display: block; }
.clear {
  display: none; width: 36px; height: 36px; flex-shrink: 0; border: 0; border-radius: 50%;
  background: var(--stub-text); color: var(--muted); align-items: center; justify-content: center;
}
.clear svg { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }

.hint { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint.is-error { color: var(--accent-text); }

.pair { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 14px; }

/* Arrival day: always worked out, nothing to fill in. */
.day .field-head { gap: 6px; }
.day-label { font-size: 14px; font-weight: 700; color: var(--muted); }
.auto {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 4px; background: #EFE8DB; color: var(--muted);
}
.day .box { border-bottom-style: dashed; }
.day-value { font-size: 14px; color: var(--muted); }
.day.is-set .box { border-bottom-color: var(--rule-strong); }
.day.is-set .day-value { font-size: 15px; font-weight: 600; color: var(--ink); }

/* Airport search results */
.combo { position: relative; }
.results {
  margin: 0; padding: 4px; list-style: none; background: #fff; border: 1.5px solid var(--ink); border-radius: 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.results li {
  min-height: 50px; padding: 6px 10px; border-radius: 9px; cursor: pointer;
  display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 8px;
}
.results li[aria-selected='true'] { background: var(--ink); color: var(--stub-text); }
.results li.empty { grid-template-columns: 1fr; cursor: default; font-size: 14px; color: var(--muted); }
.opt-code { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.opt-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.opt-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opt-place { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[aria-selected='true'] .opt-place { color: var(--stub-muted); }

/* Globe */
.globe { margin: 0; aspect-ratio: 1; }
.globe svg { display: block; width: 100%; height: 100%; }
.route-info { margin: 0; font-family: var(--mono); font-size: 13px; font-weight: 600; text-align: center; }
.route-info.is-preview { color: var(--accent-text); }
.swap {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 1.5px solid var(--rule-strong); border-radius: 999px; background: transparent; font-size: 13px; font-weight: 700;
}
.swap:hover { border-color: var(--ink); }
.swap svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Optional details */
.optional { border-top: 1.5px dashed var(--rule); padding-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.optional-fields { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr 0.7fr; gap: 14px 20px; }
.opt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.opt label { font-size: 12px; font-weight: 600; color: var(--muted); }
.opt input {
  width: 100%; min-width: 0; border: 0; border-bottom: 1.5px solid var(--rule); background: transparent; padding: 6px 0;
  font-family: var(--mono); font-size: 16px; outline: none;
}
.opt input::placeholder { font-size: 14px; }
.opt input:not(:placeholder-shown) { border-bottom-color: var(--rule-strong); }
.opt input:focus { border-bottom-color: var(--accent); }
.opt.notes { grid-column: 1 / -1; }
.optional-toggle { display: none; }

/* Stub: the calendar event */
.stub { position: relative; background: var(--ink); color: var(--stub-text); display: flex; flex-direction: column; gap: 16px; }
.stub-label { color: var(--stub-muted); }
.event-title { font-size: 20px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.event-title .missing { color: #7C8799; }
.event-rows { margin: 0; display: flex; flex-direction: column; gap: 9px; font-family: var(--mono); font-size: 13px; }
.event-rows div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--stub-rule); padding-bottom: 9px; }
.event-rows div:last-child { border-bottom: 0; padding-bottom: 0; }
.event-rows dt { color: var(--stub-muted); text-transform: uppercase; }
.event-rows dd { margin: 0; text-align: right; }
.event-rows dd.pending { color: var(--stub-muted); }
.event-line { display: none; }
.stub-space { flex-grow: 1; }
.barcode { fill: var(--stub-text); opacity: 0.3; }
.is-complete .barcode { opacity: 0.85; }
.stub-progress { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 12px; }
.pips { display: flex; gap: 4px; }
.pips i { width: 20px; height: 5px; border-radius: 3px; background: var(--disabled); }
.pips i.done { background: var(--stub-text); }
.pips i.current, .is-complete .stub .pips i { background: var(--accent); }
.actions { display: flex; flex-direction: column; gap: 16px; }
.needed { margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.45; color: var(--disabled-text); }
.download {
  width: 100%; height: 54px; border: 0; border-radius: 12px; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px;
}
.download svg { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.download:not(:disabled):hover { background: var(--accent-text); }
.download:disabled { background: var(--disabled); color: var(--disabled-text); }
.download:focus-visible { outline-color: var(--stub-text); }
/* Second choice, smaller than the download. */
.google {
  height: 40px; margin-top: -6px; border: 1.5px solid var(--disabled); border-radius: 10px; color: var(--stub-text);
  font-size: 14px; font-weight: 600; text-decoration: none; display: flex; align-items: center; justify-content: center;
}
.google:hover { color: #fff; border-color: var(--stub-muted); }
.google:focus-visible { outline-color: var(--stub-text); }
.opens-in { margin: 0; font-size: 12px; line-height: 1.4; color: var(--stub-muted); text-align: center; }

/* ---- Desktop ---- */

@media (min-width: 1180px) {
  body { padding: 36px 24px 48px; }
  .top, main { max-width: 1120px; margin: 0 auto; }
  .top { margin-bottom: 22px; }
  main { display: flex; flex-direction: column; gap: 22px; }
  .intro { display: flex; flex-direction: column; gap: 8px; }

  .ticket { position: relative; filter: drop-shadow(0 18px 28px rgba(27, 36, 51, 0.14)); }
  /* The paper, with the notches and perforation where the stub tears off punched out, so the shadow falls through them.
     It is a separate layer: a mask on .main would also clip the airport dropdown. */
  .ticket::before {
    --tear: calc(100% - 298.5px);
    content: ''; position: absolute; inset: 0; z-index: -1; border-radius: 20px;
    background: linear-gradient(to left, var(--ink) 300px, var(--ticket) 300px);
    mask:
      radial-gradient(circle at var(--tear) 0, #0000 14px, #000 14.5px),
      radial-gradient(circle at var(--tear) 100%, #0000 14px, #000 14.5px),
      radial-gradient(circle at var(--tear) 50%, #0000 1.5px, #000 2px) 0 50% / 100% 7px repeat-y;
    mask-composite: intersect;
  }
  .main { flex-grow: 1; padding: 28px 34px; gap: 20px; }
  .route { display: grid; grid-template-columns: minmax(0, 1fr) 260px minmax(0, 1fr); gap: 24px; align-items: center; }
  .side, .leg { display: flex; flex-direction: column; gap: 12px; }
  .center { display: flex; flex-direction: column; align-items: center; gap: 8px; }
  .globe { width: 100%; }
  .narrow, .end-time, .summary, .progress, .clear { display: none; }

  .results { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; width: max(100%, 310px); box-shadow: 0 18px 36px rgba(27, 36, 51, 0.22); }
  .arr .results { left: auto; right: 0; }

  .stub { width: 300px; flex-shrink: 0; background: none; padding: 30px 24px 30px 27px; }
}

/* ---- Phone (and narrow windows) ---- */

@media (max-width: 1179.98px) {
  /* The page fills at least the screen and the ticket stretches, so the download ends up at the bottom without floating over the form. */
  body { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; box-sizing: border-box; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .top, main { width: 100%; max-width: 560px; margin: 0 auto; box-sizing: border-box; }
  main { flex-grow: 1; display: flex; flex-direction: column; }
  .top { padding: 18px 20px; }
  .logo { gap: 10px; font-size: 21px; }
  .logo-mark { width: 32px; height: 32px; }
  .logo-mark svg { width: 18px; height: 18px; }
  main { padding: 0 16px; }
  .intro { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  .ticket { flex-grow: 1; flex-direction: column; gap: 12px; background: var(--ticket); border-radius: 18px; padding: 16px 18px; box-shadow: 0 12px 24px rgba(27, 36, 51, 0.1); }
  .main { gap: 12px; }

  /* Top band FROM | globe | TO, then the steps. */
  .route {
    display: grid; grid-template-columns: minmax(0, 1fr) clamp(100px, 30vw, 120px) minmax(0, 1fr); gap: 12px 6px; align-items: center;
    grid-template-areas: 'from globe to' 'info info info' 'swap swap swap' 'progress progress progress' 'dep dep dep' 'arr arr arr';
  }
  .side, .center { display: contents; }
  .dep .end { grid-area: from; }
  .arr .end { grid-area: to; align-items: flex-end; text-align: right; }
  .globe { grid-area: globe; width: 100%; }
  .route-info { grid-area: info; font-size: 12px; }
  .route-info:empty { display: none; }
  .swap { grid-area: swap; justify-self: center; min-height: 44px; }
  #dep-leg { grid-area: dep; }
  #arr-leg { grid-area: arr; }

  h2 { font-size: 11px; }
  .wide { display: none; }
  .end { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .code { font-size: clamp(30px, 10vw, 38px); line-height: 0.95; letter-spacing: 0; }
  .end-time { font-family: var(--mono); font-size: 12px; color: var(--muted); }
  .end-time:empty { display: none; }

  .progress { grid-area: progress; display: flex; align-items: center; justify-content: space-between; border-top: 1.5px dashed var(--rule); padding-top: 12px; letter-spacing: 0.1em; }
  .progress .pips i { width: 22px; background: var(--rule); }
  .progress .pips i.done { background: var(--ink); }
  .progress .pips i.current { background: var(--accent); }

  /* Only the current step takes space: done legs shrink to a summary, later steps wait. */
  .leg { display: flex; flex-direction: column; gap: 12px; }
  .leg.is-future, .leg.is-collapsed > .field, .leg.is-collapsed > .pair, .is-later { display: none; }
  .summary { display: none; align-items: center; gap: 10px; border: 1.5px solid #E4DCCD; border-radius: 12px; background: #fff; padding: 9px 12px; }
  .leg.is-collapsed .summary { display: flex; }
  .summary .badge { width: 22px; height: 22px; }
  .summary .badge svg { width: 12px; height: 12px; }
  .summary-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .summary-label { font-size: 11px; letter-spacing: 0.12em; }
  .summary-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .summary-sub { font-size: 13px; color: var(--muted); }
  .edit { min-height: 44px; border: 0; background: none; padding: 8px 4px; font-size: 14px; font-weight: 600; color: var(--accent-text); text-decoration: underline; }

  .field { gap: 6px; }
  .pair { display: flex; }
  .pair > .field { flex: 1 1 0; }
  .field-head { gap: 8px; height: 22px; }
  .field-head label { font-size: 15px; }
  .badge { width: 22px; height: 22px; font-size: 12px; }
  .box { height: 50px; }
  .is-current .box { border-radius: 10px; padding: 0 6px 0 13px; gap: 10px; }
  .clear:not([hidden]) { display: flex; }
  .airport.is-current .hint { display: none; }
  .results li { min-height: 52px; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; }
  .opt-code { font-size: 16px; }
  .opt-name { font-size: 15px; }

  .optional { border-top: 0; padding-top: 0; gap: 12px; }
  #optional-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .optional-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; text-align: left;
    border: 1.5px dashed var(--rule-strong); border-radius: 12px; background: transparent; padding: 9px 12px;
  }
  .optional-toggle svg { flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
  .optional-toggle[aria-expanded='true'] .plus-v { display: none; }
  .optional-toggle-text { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
  .optional-toggle-title { font-size: 15px; font-weight: 700; }
  .optional-toggle-title .count { font-weight: 500; color: var(--muted); }
  .optional-toggle-list { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .optional:not(.is-open) .optional-fields { display: none; }
  .optional-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
  .opt:first-child { grid-column: 1 / -1; }
  .opt input { height: 44px; }

  .stub { gap: 4px; border-radius: 12px; padding: 12px 14px; }
  .stub-label { font-size: 11px; letter-spacing: 0.12em; }
  .event-title { font-size: 16px; }
  .event-rows, .stub-space, .barcode, .stub-progress, .opens-in { display: none; }
  .event-line { display: block; font-family: var(--mono); font-size: 12px; line-height: 1.45; color: var(--disabled-text); }
  .stub { margin-top: auto; }
  .actions { gap: 10px; }
}
