/*
 * FLARM Returns theme on top of Bulma 1.0.2.
 *
 * Bulma 1.x derives every colour shade from h/s/l CSS variables at runtime,
 * so overriding those here re-themes buttons, tags, links, notifications etc.
 * without a Sass build. Brand red from the logo: #DB001B.
 *
 * Design direction: an avionics-instrument feel, not a marketing site. The
 * palette shifts Bulma's neutral greys to a cool blue-ink cast (the colour of
 * cockpit displays), and brand red is reserved as a *signal* colour — the
 * live/current state — rather than a decorative accent sprinkled everywhere.
 * The one signature element is the status track (.track), which turns the
 * device's real repair lifecycle (Accepted -> Received -> Repaired ->
 * Completed) into the flight-path of the return. Everything else stays quiet.
 */

/* --- Typeface -------------------------------------------------------- */

/* Rubik (FLARM's brand face, also used elsewhere), self-hosted, no CDN — the
 * page's CSP forbids external hosts. One variable file per subset covers the
 * 400–700 range we use. Display/headings only; body & UI keep the system
 * stack for speed and familiarity. */
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/rubik-latin.b65daadded74.woff2") format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/rubik-latin-ext.15c3dca723cb.woff2") format('woff2');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
    U+A720-A7FF;
}

/* --- Design tokens --------------------------------------------------- */

:root {
  /* Brand red (#DB001B) as HSL, so Bulma's derived shades stay on-brand. */
  --flarm-red-h: 353deg;
  --flarm-red-s: 100%;
  --flarm-red-l: 43%;
  --flarm-red: hsl(var(--flarm-red-h), var(--flarm-red-s), var(--flarm-red-l));

  /* Cool blue-ink neutrals — the instrument-panel cast that pulls the whole
     UI away from default-Bulma grey. */
  --ink: hsl(220, 18%, 13%);      /* headings, primary text            */
  --paper: hsl(220, 20%, 98%);    /* page background (not pure white)   */
  --surface: #ffffff;             /* cards, navbar                      */
  --hairline: hsl(220, 16%, 90%); /* borders, dividers                  */
  --muted: hsl(220, 10%, 46%);    /* secondary text, labels             */
  --track-future: hsl(220, 16%, 85%); /* not-yet-reached status nodes   */

  /* Display face for headings; system stacks for body and data. */
  --font-display: 'Rubik', system-ui, sans-serif;
  --font-data: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Segoe UI Mono',
    Menlo, Consolas, monospace;

  /* Retheme Bulma from the tokens above. */
  --bulma-primary-h: var(--flarm-red-h);
  --bulma-primary-s: var(--flarm-red-s);
  --bulma-primary-l: var(--flarm-red-l);
  --bulma-primary-invert-l: 100%;
  --bulma-link-h: var(--flarm-red-h);
  --bulma-link-s: var(--flarm-red-s);
  --bulma-link-l: var(--flarm-red-l);
  --bulma-focus-h: var(--flarm-red-h);
  --bulma-focus-s: var(--flarm-red-s);
  --bulma-title-color: var(--ink);
  --bulma-body-background-color: var(--paper);

  /* Rubik for every Bulma title/subtitle, with tightened tracking. */
  --bulma-title-family: var(--font-display);
  --bulma-subtitle-family: var(--font-display);
}

body {
  background-color: var(--paper);
}

/* Headings in the display face, tightened. Weight/spacing carry the
   personality; the type scale stays Bulma's so layouts don't shift. */
.title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.subtitle {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Page-header trio spacing (eyebrow / title / subtitle). Targets only the
   header pattern -- an eyebrow immediately followed by a title -- so the
   section-label eyebrows inside boxes (which set their own mb-* utilities)
   are untouched. Bulma leaves the eyebrow flush against the title and pulls a
   title-following subtitle in tight, so the whole trio reads as one cramped
   block; these give each element room to breathe. */
.eyebrow:has(+ .title) {
  margin-bottom: 0.5rem;
}
.title + .subtitle {
  margin-top: 0.75rem;
}

/* Serial numbers, login codes, timestamps: machine identifiers, set as such. */
.is-data,
.serial {
  font-family: var(--font-data);
  font-feature-settings: 'tnum' 1;  /* tabular figures — columns line up */
}

/* Eyebrow label: small uppercase caption for section headers and stat tiles. */
.eyebrow {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- Sticky footer --------------------------------------------------- */

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > main {
  flex: 1;
}

/* --- Navbar ---------------------------------------------------------- */

.navbar.is-flarm {
  background-color: var(--surface);
  border-top: 4px solid var(--flarm-red);
  border-bottom: 1px solid var(--hairline);
}

.navbar.is-flarm .navbar-item img {
  /* The stacked FLARM logo needs more height than Bulma's 1.75rem cap. */
  max-height: 2.5rem;
}

.navbar.is-flarm .navbar-app-name {
  margin-left: 0.75rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--hairline);
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink);
}

/* Underline-on-hover for the partner nav links — quiet until you reach. */
.navbar.is-flarm .navbar-start .navbar-item {
  border-bottom: 2px solid transparent;
}
.navbar.is-flarm .navbar-start .navbar-item:hover {
  background-color: transparent;
  border-bottom-color: var(--flarm-red);
  color: var(--ink);
}

/* --- Auth pages ------------------------------------------------------ */

.auth-logo {
  height: 5rem;
}

/* The login code is a machine token — set it large, mono and spaced so it's
   easy to read against the emailed code while typing. */
input.passcode-input {
  font-family: var(--font-data);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-align: center;
  padding-left: 0.4em;  /* offset the trailing letter-spacing so it centres */
}

/* --- Footer ---------------------------------------------------------- */

.footer.is-flarm {
  background-color: var(--ink);
  color: hsl(220, 12%, 68%);
  padding: 2.5rem 1.5rem;
  border-top: 4px solid var(--flarm-red);
}

.footer.is-flarm a {
  color: hsl(220, 14%, 88%);
}

.footer.is-flarm a:hover {
  color: #fff;
  text-decoration: underline;
}

/* --- Cards ----------------------------------------------------------- */

/* Flat corporate look — a hairline instead of Bulma's heavy shadow. */
.box {
  --bulma-box-shadow: 0 1px 2px hsla(220, 40%, 10%, 0.05);
  border: 1px solid var(--hairline);
}

/* =====================================================================
   SIGNATURE: the status track
   The device's repair lifecycle as a flight path. Nodes are the logo's
   radiating-arc motif rendered as concentric rings; the reached path is
   brand red, the current node carries a slow ambient pulse, and future
   nodes are hairline-grey. Numbering is legitimate here — it's the real
   ordered lifecycle the customer is asking about, not decoration.
   ===================================================================== */

.track {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.track-step {
  flex: 1 1 0;
  position: relative;
  text-align: center;
  padding-top: 3.25rem;   /* room for the node above the label */
  min-width: 0;
}

/* The connector line, drawn behind the nodes. Each step owns the segment to
   its left; the first step suppresses it. */
.track-step::before {
  content: '';
  position: absolute;
  top: 1.25rem;           /* vertically centred on the 1rem-radius node */
  right: 50%;
  left: -50%;
  height: 2px;
  background: var(--track-future);
  z-index: 0;
}
.track-step:first-child::before {
  display: none;
}

/* The node: a ring with a numbered core. */
.track-node {
  position: absolute;
  top: 0.25rem;
  left: 50%;
  transform: translateX(-50%);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--track-future);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8125rem;
  color: var(--muted);
  z-index: 1;
}
.track-node::before {
  counter-increment: step;
  content: counter(step);
}

.track-label {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
  display: block;
  padding: 0 0.25rem;
}

/* Reached (done) steps: filled red path and node. */
.track-step.is-done::before {
  background: var(--flarm-red);
}
.track-step.is-done .track-node {
  background: var(--flarm-red);
  border-color: var(--flarm-red);
  color: #fff;
}
/* Done nodes show a check, not a number — the step is behind you. */
.track-step.is-done .track-node::before {
  content: '\2713';   /* ✓ */
  counter-increment: step;  /* keep the counter advancing for later steps */
}
.track-step.is-done .track-label {
  color: var(--ink);
}

/* Current step: the live signal. Red ring, red number, and a slow radiating
   pulse — the one animation in the whole UI. */
.track-step.is-current::before {
  background: var(--flarm-red);
}
.track-step.is-current .track-node {
  border-color: var(--flarm-red);
  color: var(--flarm-red);
  box-shadow: 0 0 0 0 hsla(var(--flarm-red-h), var(--flarm-red-s), var(--flarm-red-l), 0.5);
  animation: track-pulse 2.4s ease-out infinite;
}
.track-step.is-current .track-label {
  color: var(--flarm-red);
  font-weight: 700;
}

@keyframes track-pulse {
  0%   { box-shadow: 0 0 0 0 hsla(var(--flarm-red-h), var(--flarm-red-s), var(--flarm-red-l), 0.45); }
  70%  { box-shadow: 0 0 0 0.6rem hsla(var(--flarm-red-h), var(--flarm-red-s), var(--flarm-red-l), 0); }
  100% { box-shadow: 0 0 0 0 hsla(var(--flarm-red-h), var(--flarm-red-s), var(--flarm-red-l), 0); }
}

@media (prefers-reduced-motion: reduce) {
  .track-step.is-current .track-node {
    animation: none;
    /* Keep a static ring so "current" is still visually distinct. */
    box-shadow: 0 0 0 0.25rem hsla(var(--flarm-red-h), var(--flarm-red-s), var(--flarm-red-l), 0.15);
  }
}

/* On narrow screens the track turns vertical so labels stay readable. */
@media (max-width: 48rem) {
  .track {
    flex-direction: column;
    padding-left: 0.5rem;
  }
  .track-step {
    flex: none;
    text-align: left;
    padding: 0 0 1.5rem 3rem;
    min-height: 2.5rem;
  }
  .track-step:last-child {
    padding-bottom: 0;
  }
  .track-node {
    top: 0;
    left: 0;
    transform: none;
  }
  .track-step::before {
    top: -0.75rem;
    left: 1rem;         /* centre of the 2rem node */
    right: auto;
    bottom: 50%;
    width: 2px;
    height: auto;
  }
  .track-label {
    padding: 0.375rem 0 0 0;
  }
}

/* --- Status pill (lists) --------------------------------------------- */

/* A quieter, more legible status marker than a bare Bulma tag: a dot + label
   whose colour tracks the lifecycle stage. */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}
.status-pill::before {
  content: '';
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--track-future);
  flex: none;
}
.status-pill.is-active::before {
  background: var(--flarm-red);
}
.status-pill.is-complete::before {
  background: hsl(145, 50%, 42%);   /* completed = settled green */
}

/* --- Case rows (list cards) ------------------------------------------ */

/* Lists move from striped tables to quiet cards: a left rule that lights up
   red on hover (the "signal" motif again), the serials in the data face. */
.case-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--hairline);
  border-radius: var(--bulma-radius, 0.5rem);
  box-shadow: 0 1px 2px hsla(220, 40%, 10%, 0.05);
  margin-bottom: 0.6rem;
  color: inherit;
  transition: border-color 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
a.case-card:hover {
  border-left-color: var(--flarm-red);
  transform: translateX(2px);
  box-shadow: 0 2px 8px hsla(220, 40%, 10%, 0.08);
}
.case-card .case-serial {
  font-family: var(--font-data);
  font-weight: 500;
  color: var(--ink);
}
.case-card .case-meta {
  color: var(--muted);
  font-size: 0.8125rem;
}
.case-card .case-grow {
  flex: 1 1 auto;
  min-width: 0;
}

/* --- Summary bar (detail header) ------------------------------------- */

/* Small labelled facts across the top of a detail page. */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--bulma-radius, 0.5rem);
}
.summary-item {
  min-width: 0;
}
.summary-item .summary-value {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--ink);
}
.summary-item .summary-value.is-data {
  font-family: var(--font-data);
}

/* --- File drop zone (test-log attachments) --------------------------- */

/* Progressive enhancement over the native multi-file input (which is hidden
   but kept for submission and the JS-off fallback). See the drop-zone script
   in cases/partner/case_detail.html. */
.file-dropzone {
  border: 1.5px dashed var(--hairline);
  border-radius: var(--bulma-radius, 0.5rem);
  padding: 1.5rem 1.25rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s ease, background-color 0.12s ease,
    color 0.12s ease;
}
/* Children don't intercept drag events, so dragenter/leave fire only at the
   zone boundary (no flicker) -- and clicks still fall through to the zone. */
.file-dropzone > * {
  pointer-events: none;
}
.file-dropzone:hover {
  border-color: var(--muted);
}
.file-dropzone:focus-visible {
  outline: none;
  border-color: var(--flarm-red);
  box-shadow: 0 0 0 3px hsla(var(--flarm-red-h), var(--flarm-red-s), var(--flarm-red-l), 0.25);
}
.file-dropzone.is-dragover {
  border-color: var(--flarm-red);
  background-color: hsla(var(--flarm-red-h), var(--flarm-red-s), var(--flarm-red-l), 0.04);
  color: var(--ink);
}
.file-dropzone-prompt {
  margin: 0;
  font-size: 0.9rem;
}
.file-dropzone-browse {
  color: var(--flarm-red);
  font-weight: 500;
  text-decoration: underline;
}
.file-dropzone-list {
  list-style: none;
  margin: 0.85rem 0 0 0;
  padding: 0;
  text-align: left;
}
.file-dropzone-list li {
  font-family: var(--font-data);
  font-size: 0.8125rem;
  color: var(--ink);
  padding: 0.3rem 0.1rem;
  border-top: 1px solid var(--hairline);
}

/* Honeypot field (accounts.forms.EmailForm.hp_token): pushed off-screen rather
   than display:none -- some bots skip hidden fields but still fill positioned
   ones. Hide the input and its whole crispy-bulma .field row so no empty gap
   shows. Paired with tabindex=-1 / aria-hidden on the widget for humans and
   assistive tech. */
.hp-field,
.field:has(> .control > .hp-field) {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
