/************************************************************************************************/
/* DESIGN TOKENS                                                                                   */
/* Light, high-contrast "official government portal" language instead of the dark highway-sign     */
/* look. Two accent colours carry the border identity: Old Glory Blue for the U.S.-bound side,      */
/* Canada red for the Canada-bound side. Severity (short/moderate/long wait) is a separate signal   */
/* deliberately kept out of the red/blue family so the two meanings never collide.                 */
/************************************************************************************************/
:root {
  --ink:        #12181F;
  --paper:      #FFFFFF;
  --surface:    #F3F5F7;
  --border:     #D7DCE1;
  --muted:      #5B6672;

  --header-bg:  #0B1420;
  --header-text:#F4F6F8;

  --us:         #0A3161;
  --us-tint:    #E9EEF5;
  --ca:         #A6192E;
  --ca-tint:    #F7E9EB;

  --sev-good:   #1E8A5F;
  --sev-good-tint: #E7F3EE;
  --sev-fair:   #A6690B;
  --sev-fair-tint: #FBF1E1;
  --sev-bad:    #C1440E;
  --sev-bad-tint:  #FBEAE2;

  --community:      #5B3E96;
  --community-tint: #EFE9F7;

  --font-display: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body:    'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'IBM Plex Mono', 'Courier New', monospace;

  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; padding-bottom: 3rem; }
a { color: var(--us); }
body.dir-ca a { color: var(--ca); }

/************************************************************************************************/
/* HEADER                                                                                          */
/************************************************************************************************/
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  background: var(--header-bg);
  color: var(--header-text);
}

.brand { display: flex; align-items: center; gap: 0.75rem; }

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
  color: var(--header-text);
}

.brand p { margin: 0; font-size: 0.78rem; color: #8B97A3; }

.status-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #A9B3BC;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sev-good);
  box-shadow: 0 0 0 0 rgba(30, 138, 95, 0.6);
  animation: pulse 2.4s infinite;
}

@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(30, 138, 95, 0.5); }
  70%  { box-shadow: 0 0 0 7px rgba(30, 138, 95, 0); }
  100% { box-shadow: 0 0 0 0 rgba(30, 138, 95, 0); }
}

.refresh-btn {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--header-bg);
  background: var(--header-text);
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}

.refresh-btn:hover { filter: brightness(0.92); }
.refresh-btn:focus-visible,
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--us);
  outline-offset: 2px;
}
body.dir-ca .refresh-btn:focus-visible,
body.dir-ca button:focus-visible { outline-color: var(--ca); }

/************************************************************************************************/
/* ACCOUNT WIDGET (header)                                                                          */
/************************************************************************************************/
.account-widget {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.account-email { color: var(--header-text); }
.account-reputation { color: #A9B3BC; }

.account-btn {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--header-text);
  background: transparent;
  border: 1px solid #3A4552;
  border-radius: 4px;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}
.account-btn:hover { background: #1A2634; }
.account-btn-primary { color: var(--header-bg); background: var(--header-text); border-color: var(--header-text); }
.account-btn-primary:hover { filter: brightness(0.92); background: var(--header-text); }

/************************************************************************************************/
/* LAYOUT                                                                                          */
/************************************************************************************************/
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 3rem) 0;
}

.page-intro {
  max-width: 68ch;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 0 1.5rem;
}
.page-intro strong { color: var(--ink); }

/************************************************************************************************/
/* DIRECTION SWITCH                                                                                */
/* A rectangular, government-language-toggle-style control (think EN/FR switchers on official       */
/* portals) instead of a soft pill. Active segment fills solid with that direction's nation colour. */
/************************************************************************************************/
.direction-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.direction-tab {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--paper);
  border: none;
  padding: 0.65rem 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  white-space: nowrap;
}

.tab-us + .tab-ca { border-left: 1px solid var(--border); }

.direction-tab-sub { font-size: 0.68rem; font-weight: 400; opacity: 0.8; }

.direction-tab.tab-us.active { color: #fff; background: var(--us); }
.direction-tab.tab-ca.active { color: #fff; background: var(--ca); }

.direction-tab:not(.active):hover { color: var(--ink); background: var(--surface); }

.direction-caption {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1.75rem;
}

.roadmap-note {
  max-width: 62ch;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 2rem 0 0;
}

.crossings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}

/************************************************************************************************/
/* CROSSING CARD                                                                                   */
/* One dominant number, colour-coded by wait severity (never by nation, to keep the two signals    */
/* from colliding). The left edge carries the *nation* colour of whichever direction is active.     */
/************************************************************************************************/
.sign-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

body.dir-us .sign-card { border-left-color: var(--us); }
body.dir-ca .sign-card { border-left-color: var(--ca); }

/* Name on its own row, pills on their own row below it - always two rows, on every card,
   regardless of name length or whether the "Fastest now" badge is present. A single flex row
   would wrap the pills under the name only on some cards (whichever name + badge combo is too
   wide), pushing the estimate band below down further on just that card and breaking row
   alignment across the grid. */
.sign-card-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.crossing-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  margin: 0;
  line-height: 1.25;
}

.header-right { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; }

.status-pill {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}
.status-pill.open    { background: var(--sev-good-tint); color: var(--sev-good); }
.status-pill.closed  { background: var(--surface); color: var(--muted); }
.status-pill.unknown { background: var(--surface); color: var(--muted); }

.fastest-badge {
  font-family: var(--font-body);
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--ink);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}

/************************************************************************************************/
/* ESTIMATE BAND                                                                                   */
/* The site's own number - blends official + community data (see community.php blend_combined()). */
/* This is the card's hero: biggest number, its own tinted panel, an accuracy badge explaining how  */
/* much to trust it. Severity still drives the number's colour, same language as the rest of the    */
/* site; the badge is a separate signal for how the number was reached, not how bad the wait is.    */
/************************************************************************************************/
.estimate-band {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.3rem;
}

.estimate-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.estimate-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.estimate-badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
}
.estimate-badge.badge-high     { background: var(--sev-good-tint); color: var(--sev-good); }
.estimate-badge.badge-moderate { background: var(--sev-fair-tint); color: var(--sev-fair); }
.estimate-badge.badge-low      { background: var(--sev-bad-tint);  color: var(--sev-bad); }

/* grid, not flex: centers the number itself in the middle column - a flex row centered as a group */
/* would put the midpoint between the number and "min" at the box's center, not the number itself. */
.estimate-value-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  width: 100%;
}
.estimate-value-row .estimate-value { grid-column: 2; justify-self: center; }
.estimate-value-row .estimate-unit { grid-column: 3; justify-self: start; margin-left: 0.35rem; }

.estimate-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 2.75rem;
  line-height: 1;
}
.estimate-value.sev-good   { color: var(--sev-good); }
.estimate-value.sev-fair   { color: var(--sev-fair); }
.estimate-value.sev-bad    { color: var(--sev-bad); }
.estimate-value.sev-closed { color: var(--muted); font-size: 1.4rem; font-family: var(--font-body); font-weight: 600; }

.estimate-unit { font-size: 0.85rem; color: var(--muted); }

.estimate-empty { width: 100%; font-size: 0.85rem; color: var(--muted); margin: 0.1rem 0 0; }

.estimate-detail {
  width: 100%;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.1rem 0 0;
}

/************************************************************************************************/
/* SOURCES ROW - official and community, side by side with equal visual weight. Same column width, */
/* same number size, same label treatment - neither one is the "real" number and the other a note.  */
/************************************************************************************************/
.sources-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.source-col {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

.source-col-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.source-value-row { display: flex; align-items: baseline; gap: 0.35rem; }

.source-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.7rem;
  line-height: 1;
}
.source-value.sev-good   { color: var(--sev-good); }
.source-value.sev-fair   { color: var(--sev-fair); }
.source-value.sev-bad    { color: var(--sev-bad); }
.source-value.sev-closed { color: var(--muted); font-size: 1.1rem; font-family: var(--font-body); font-weight: 600; }

.source-unit { font-size: 0.72rem; color: var(--muted); }

.source-col-meta {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: var(--muted);
  margin: 0;
}

.source-col-empty {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.1rem 0 0;
}

.secondary-line {
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
}

.secondary-line strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
}

/**/
/* extra lanes - opt-in detail, not default real estate */
.lane-details summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--us);
}
body.dir-ca .lane-details summary { color: var(--ca); }
.lane-details summary::-webkit-details-marker { display: none; }
.lane-details summary::before { content: '+ '; }
.lane-details[open] summary::before { content: '\2212 '; }

.lane-details .lane-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.4rem 0 0;
  gap: 0.75rem;
}

.lane-details .lane-row-left {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lane-details .lane-row strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 600;
  flex-shrink: 0;
}

.lane-details .lane-row-meta {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

/**/
/* port notice (e.g. Ready Lane hours) - real CBP data, but routine/frequent, not an alert,     */
/* so it rides the same quiet toggle pattern as the extra lanes instead of a bordered callout   */
.notice-details summary { text-transform: none; }

.notice-body {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0.5rem 0 0;
  overflow-wrap: anywhere;
}

.notice-body a { color: inherit; text-decoration: underline; }

/************************************************************************************************/
/* OTHER-DIRECTION LINE                                                                            */
/* The data we still have, just not the star of the card: the opposite direction's headline        */
/* number, tagged with its own source colour, tucked at the bottom instead of hidden entirely.     */
/************************************************************************************************/
.other-direction {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding-top: 0.7rem;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

.other-direction-left {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
}

.other-direction strong {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
}

.source-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
.source-tag.us { background: var(--us-tint); color: var(--us); }
.source-tag.ca { background: var(--ca-tint); color: var(--ca); }
.source-tag.community { background: var(--community-tint); color: var(--community); }

.direction-empty {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

/************************************************************************************************/
/* COMMUNITY REPORTING (the report/auth modals + the "Report a time" button in the community column) */
/************************************************************************************************/
.community-report-btn {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--community);
  background: var(--community-tint);
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.6rem;
  margin-top: 0.2rem;
  cursor: pointer;
  white-space: nowrap;
  align-self: flex-start;
}
.community-report-btn:hover { filter: brightness(0.96); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 20, 32, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}
.modal-overlay[hidden] { display: none; }

.modal {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(11, 20, 32, 0.25);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}

.modal-tabs { display: flex; gap: 1.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.modal-tab {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0 0 0.6rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.modal-tab.active { color: var(--ink); border-bottom-color: var(--us); }

.modal-title { font-size: 1.05rem; margin: 0 0 0.35rem; }
.modal-sub { font-size: 0.8rem; color: var(--muted); margin: 0 0 1rem; }
.modal-error {
  font-size: 0.8rem;
  color: var(--sev-bad);
  background: var(--sev-bad-tint);
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  margin: 0 0 1rem;
}

.field-label { display: block; font-size: 0.78rem; font-weight: 600; margin: 0 0 0.3rem; }
.field-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 1rem;
}
.field-input:focus-visible { outline: 2px solid var(--us); outline-offset: 1px; }

.modal-submit {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  background: var(--us);
  border: none;
  border-radius: 4px;
  padding: 0.7rem;
  cursor: pointer;
}
.modal-submit:hover { filter: brightness(0.92); }

/************************************************************************************************/
/* FAQ                                                                                             */
/* Native <details>/<summary> - accessible and crawlable with no JS, and its collapsed state still  */
/* counts as visible content for FAQPage rich results (Google renders it either way).               */
/************************************************************************************************/
.faq-section {
  max-width: 68ch;
  margin: 2.5rem 0 0;
}

.faq-section h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 0.9rem;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
}
.faq-item:first-of-type { border-top: 1px solid var(--border); }

.faq-item summary {
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.faq-item summary::marker { color: var(--muted); }

.faq-item p {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

/************************************************************************************************/
/* FOOTER                                                                                          */
/************************************************************************************************/
.site-footer {
  max-width: 1180px;
  margin: 2.5rem auto 0;
  padding: 1.25rem clamp(1rem, 4vw, 3rem) 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.error-banner {
  background: var(--sev-bad-tint);
  border: 1px solid var(--sev-bad);
  color: var(--ink);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  display: none;
}

.error-banner.visible { display: block; }

.info-banner {
  background: var(--us-tint);
  border: 1px solid var(--us);
  color: var(--ink);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  display: none;
}
body.dir-ca .info-banner { background: var(--ca-tint); border-color: var(--ca); }

.info-banner.visible { display: block; }

.skeleton {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/************************************************************************************************/
/* SMALL SCREENS                                                                                   */
/* Below this width the direction switch stacks label-over-sublabel per tab (instead of wrapping    */
/* mid-word), the grid forces a guaranteed single column, and the headline number steps down a      */
/* size so it never crowds the card edges.                                                          */
/************************************************************************************************/
@media (max-width: 480px) {
  .direction-switch {
    display: flex;
    width: 100%;
  }

  .direction-tab {
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    white-space: normal;
    text-align: center;
    padding: 0.55rem 0.4rem;
  }

  .direction-tab-sub { font-size: 0.62rem; }

  .crossings-grid { grid-template-columns: 1fr; }

  .sign-card { padding: 1.1rem 1.15rem; }

  .estimate-value { font-size: 2.3rem; }
  .estimate-value.sev-closed { font-size: 1.25rem; }

  .sources-row { gap: 0.6rem; }
  .source-value { font-size: 1.4rem; }
  .source-value.sev-closed { font-size: 1rem; }

  .status-line { width: 100%; justify-content: flex-end; }
  .account-widget { width: 100%; justify-content: flex-end; }
  .modal { padding: 1.4rem; }
}
