/* =====================================================================
   Motion Dynamics — design tokens
   Colors, typography, spacing, radii, shadows, motion.
   LIGHT-FIRST, iOS-grade touchscreen HMI aesthetic.

   The leading surface is MD EDGE — the on-device touchscreen OS. Its
   visual language (soft grouped cards on a light grey field, Inter for
   everything, a single brand-amber accent, generous rounding) is the
   source of truth for the whole system. MD MESH and the marketing site
   inherit it.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700&family=Michroma&display=swap');

:root {
  /* ---------- Color: surfaces (light, grouped) ---------- */
  --md-bg:        #F2F2F7;   /* systemGroupedBackground — the page/field */
  --md-elev:      #FFFFFF;   /* raised surface: cards, rows, sheets */
  --md-elev-2:    #FBFBFD;   /* faintly recessed white (nested groups) */
  --md-fill:      rgba(118,118,128,0.12);  /* secondary fill: tracks, chips, segmented */
  --md-fill-2:    rgba(118,118,128,0.08);  /* tertiary fill: pressed, hairline tint */
  --md-sep:       rgba(60,60,67,0.13);     /* hairline separators (on white) */
  --md-sep-bold:  #D1D1D6;                 /* opaque divider where contrast is needed */

  /* ---------- Color: text scale (iOS label hierarchy) ---------- */
  --md-label:     #1C1C1E;   /* primary text, titles */
  --md-label-2:   #6C6C70;   /* secondary text, subtitles */
  --md-label-3:   #AEAEB2;   /* tertiary text, placeholder, chevrons */
  --md-label-4:   #C7C7CC;   /* quaternary, faint */
  --md-white:     #FFFFFF;

  /* ---------- Color: brand + signal ---------- */
  --md-amber:      #FFC400;  /* brand accent — fills, active state, primary CTA */
  --md-amber-deep: #946A00;  /* accessible amber for TEXT/icons on white */
  --md-amber-tint: rgba(255,196,0,0.18);   /* tinted-button background */
  --md-amber-12:   rgba(255,196,0,0.12);
  --md-green:      #34C759;  /* online, nominal, success, toggle-on */
  --md-green-tint: rgba(52,199,89,0.12);
  --md-red:        #FF3B30;  /* hazard, stop, error, destructive */
  --md-red-tint:   rgba(255,59,48,0.12);
  --md-orange:     #FF9500;  /* warning, attention, due-soon */
  --md-blue:       #007AFF;  /* informational links / secondary action */

  /* ---------- Semantic aliases (foreground / background) ----------
     Kept from the previous (dark) system so dependent kits remap
     automatically. Elevation now climbs LIGHTER-on-GREY (bg → white),
     the inverse of the old darker-by-elevation rule. */
  --fg-1: var(--md-label);
  --fg-2: var(--md-label-2);
  --fg-3: var(--md-label-3);
  --fg-accent: var(--md-amber-deep);

  --bg-0: var(--md-bg);      /* page / outer field */
  --bg-1: var(--md-elev);    /* primary raised surface (cards, rows) */
  --bg-2: var(--md-elev);    /* raised surface (kept = white) */
  --fill-1: var(--md-fill);  /* secondary fill */

  --border-1: var(--md-sep);
  --border-2: var(--md-sep-bold);
  --border-accent: var(--md-amber);

  /* ---------- Typography stacks ----------
     Inter is the single UI voice — headings, labels, body, numbers.
     Michroma is brand-only (the MD / MD EDGE / MD MESH wordmark).
     There is NO monospace UI voice in this system. */
  --font-sans:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-brand: 'Michroma', 'Inter', system-ui, sans-serif;
  --font-num:   'Inter', system-ui, -apple-system, sans-serif; /* pair with .md-num for tabular */
  /* Back-compat alias — the retired mono voice now resolves to Inter. */
  --font-mono:  var(--font-sans);

  /* ---------- Type scale (iOS-grade) ---------- */
  --t-eyebrow-size: 13px;   /* grouped-list section header */
  --t-eyebrow-lh: 16px;
  --t-eyebrow-track: 0.04em;

  --t-meta-size: 13px;      /* metadata / footnote */
  --t-meta-lh: 18px;

  --t-body-sm-size: 14px;
  --t-body-sm-lh: 20px;
  --t-body-size: 16px;      /* row title / default body */
  --t-body-lh: 22px;

  --t-h3-size: 20px;        /* card title */
  --t-h3-lh: 25px;
  --t-h2-size: 28px;        /* large navigation title */
  --t-h2-lh: 33px;
  --t-h1-size: 40px;        /* screen hero */
  --t-h1-lh: 44px;
  --t-display-size: 80px;   /* marketing hero — Michroma */
  --t-display-lh: 82px;
  --t-display-track: 0.01em;

  /* ---------- Spacing (4-based) ---------- */
  --s-1:   4px;
  --s-2:   8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-7:  32px;
  --s-8:  48px;
  --s-9:  64px;
  --s-10: 96px;

  /* ---------- Radii (generous, iOS-soft) ---------- */
  --r-chip:    8px;   /* chips, small fills */
  --r-control:12px;   /* segmented control, compact buttons, inputs */
  --r-row:    13px;   /* standalone tappable rows */
  --r-btn:    16px;   /* primary touch buttons */
  --r-group:  18px;   /* inset grouped-list container */
  --r-card:   22px;   /* hero / feature cards */
  --r-sheet:  28px;   /* modal sheets, device corners */
  --r-pill:  999px;   /* toggles, status dots, capsule tags */

  /* ---------- Shadows (soft, ambient — never hard) ---------- */
  --shadow-row:   0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.04);
  --shadow-card:  0 1px 2px rgba(0,0,0,0.04), 0 10px 30px rgba(0,0,0,0.05);
  --shadow-pop:   0 12px 40px rgba(0,0,0,0.18);
  --shadow-tabbar:0 -0.5px 0 rgba(60,60,67,0.13);

  /* ---------- Motion (iOS easing) ---------- */
  --ease:      cubic-bezier(0.4, 0.1, 0.2, 1); /* @kind other */
  --ease-out:  cubic-bezier(0.2, 0, 0, 1); /* @kind other */
  --dur-fast:  180ms; /* @kind other */
  --dur-mid:   250ms; /* @kind other */
  --dur-slow:  400ms; /* @kind other */

  /* ---------- Grid / layout ---------- */
  --container-max: 1200px;
  --gutter-desktop: 48px;
  --gutter-mobile: 20px;
  --col-gap: 24px;
  --edge-w: 1024px;   /* MD EDGE panel — fixed */
  --edge-h: 600px;
}

/* =====================================================================
   Semantic element styles — drop this CSS in and .md-* classes work.
   ===================================================================== */

.md-root {
  background: var(--bg-0);
  color: var(--fg-1);
  font-family: var(--font-sans);
  font-size: var(--t-body-size);
  line-height: var(--t-body-lh);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.md-page { background: var(--bg-0); min-height: 100vh; }

/* Brand wordmark — Michroma, brand-only. */
.md-wordmark {
  font-family: var(--font-brand);
  letter-spacing: 0.05em;
  color: var(--md-label);
  font-weight: 400;
}
.md-wordmark .accent { color: var(--md-amber-deep); }

/* Grouped-list section header (the old "eyebrow"). UPPER, tracked, secondary. */
.md-eyebrow {
  font-family: var(--font-sans);
  font-size: var(--t-eyebrow-size);
  line-height: var(--t-eyebrow-lh);
  letter-spacing: var(--t-eyebrow-track);
  text-transform: uppercase;
  color: var(--fg-2);
  font-weight: 600;
}
.md-eyebrow--amber { color: var(--md-amber-deep); }

/* Footnote / metadata — sentence or caps, secondary. */
.md-meta {
  font-family: var(--font-sans);
  font-size: var(--t-meta-size);
  line-height: var(--t-meta-lh);
  color: var(--fg-2);
}
.md-meta strong { color: var(--fg-1); font-weight: 600; }

/* Headings — all Inter, tight tracking, label color. */
.md-h1, h1.md {
  font-family: var(--font-sans);
  font-size: var(--t-h1-size);
  line-height: var(--t-h1-lh);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg-1);
  margin: 0;
}
.md-h2, h2.md {
  font-family: var(--font-sans);
  font-size: var(--t-h2-size);
  line-height: var(--t-h2-lh);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--fg-1);
  margin: 0;
}
.md-h3, h3.md {
  font-family: var(--font-sans);
  font-size: var(--t-h3-size);
  line-height: var(--t-h3-lh);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg-1);
  margin: 0;
}

/* Marketing hero — the one place Michroma sets large display type. */
.md-display {
  font-family: var(--font-brand);
  font-size: var(--t-display-size);
  line-height: var(--t-display-lh);
  letter-spacing: var(--t-display-track);
  font-weight: 400;
  color: var(--fg-1);
  margin: 0;
}

/* Body */
.md-p, p.md {
  font-family: var(--font-sans);
  font-size: var(--t-body-size);
  line-height: var(--t-body-lh);
  color: var(--fg-2);
  margin: 0;
  text-wrap: pretty;
}
.md-p-sm, p.md-sm {
  font-family: var(--font-sans);
  font-size: var(--t-body-sm-size);
  line-height: var(--t-body-sm-lh);
  color: var(--fg-2);
}

/* Tabular numeric — telemetry, clocks, temperatures. Inter + tnum. */
.md-num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum', 'cv01';
  letter-spacing: 0;
}

/* Link */
.md-a, a.md {
  color: var(--md-amber-deep);
  text-decoration: none;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: opacity var(--dur-fast) var(--ease);
}
.md-a:hover, a.md:hover { opacity: 0.7; }

/* --- Buttons ------------------------------------------------------ */
.md-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.01em;
  height: 50px;
  padding: 0 22px;
  border-radius: var(--r-btn);
  border: none;
  background: var(--md-fill);
  color: var(--md-label);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
  text-decoration: none;
}
.md-btn:active { opacity: 0.7; }
.md-btn:focus-visible { outline: 3px solid var(--md-amber); outline-offset: 2px; }

/* Primary — filled brand amber, dark label (amber is bright). */
.md-btn--primary {
  background: var(--md-amber);
  color: var(--md-label);
}
.md-btn--primary:active { background: #E6B000; }

/* Tinted — soft amber wash, deep-gold label. */
.md-btn--tinted {
  background: var(--md-amber-tint);
  color: var(--md-amber-deep);
}
/* Destructive tinted */
.md-btn--danger {
  background: var(--md-red-tint);
  color: var(--md-red);
}
/* Plain / ghost — text only. */
.md-btn--ghost {
  background: transparent;
  color: var(--md-amber-deep);
}
.md-btn--ghost:hover { background: var(--md-fill-2); }

.md-btn[disabled] {
  color: var(--fg-3);
  background: var(--md-fill-2);
  cursor: not-allowed;
  opacity: 1;
}

/* --- Inputs ------------------------------------------------------- */
.md-input {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.3;
  color: var(--fg-1);
  background: var(--md-elev);
  border: 1px solid var(--md-sep);
  border-radius: var(--r-control);
  padding: 13px 14px;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  width: 100%;
  box-sizing: border-box;
}
.md-input::placeholder { color: var(--fg-3); }
.md-input:focus { outline: none; border-color: var(--md-amber); box-shadow: 0 0 0 4px var(--md-amber-12); }

/* Search / filled field (grouped fill, no border). */
.md-field {
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--fg-1);
  background: var(--md-fill);
  border: none;
  border-radius: var(--r-control);
  padding: 12px 14px;
  width: 100%;
  box-sizing: border-box;
}
.md-field::placeholder { color: var(--fg-3); }
.md-field:focus { outline: none; box-shadow: 0 0 0 4px var(--md-amber-12); }

/* --- Card --------------------------------------------------------- */
.md-card {
  background: var(--md-elev);
  border: none;
  border-radius: var(--r-card);
  padding: var(--s-5);
  box-shadow: var(--shadow-card);
  position: relative;
}
.md-card--quiet { background: transparent; box-shadow: none; }

/* --- Inset grouped list (the iOS Settings pattern) ---------------- */
.md-group {
  background: var(--md-elev);
  border-radius: var(--r-group);
  box-shadow: var(--shadow-row);
  overflow: hidden;
}
.md-group__header {
  font-size: var(--t-eyebrow-size);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--t-eyebrow-track);
  color: var(--fg-2);
  padding: 0 18px 6px;
}
.md-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  min-height: 52px;
  background: var(--md-elev);
}
.md-row + .md-row { box-shadow: inset 0 1px 0 var(--md-sep); margin-left: 0; }
.md-row__icon {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--md-amber); color: #fff;
}
.md-row__body { flex: 1; min-width: 0; padding: 9px 0; }
.md-row__title { font-size: 16px; font-weight: 450; color: var(--md-label); line-height: 1.2; }
.md-row__sub { font-size: 13px; color: var(--md-label-2); margin-top: 1px; }
.md-row__value { font-size: 16px; color: var(--md-label-2); }

/* --- Status dot --------------------------------------------------- */
.md-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--md-green);
  vertical-align: middle;
  box-shadow: 0 0 0 4px rgba(52,209,88,0.18);
}
.md-dot--amber { background: var(--md-amber); box-shadow: 0 0 0 4px var(--md-amber-tint); }
.md-dot--red   { background: var(--md-red);   box-shadow: 0 0 0 4px var(--md-red-tint); }
.md-dot--mute  { background: var(--md-label-3); box-shadow: 0 0 0 4px rgba(174,174,178,0.18); }

/* Live pulse for "online" indicators */
@keyframes md-tick { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.md-dot--live { animation: md-tick 2s var(--ease) infinite; }

/* --- Chip / capsule tag ------------------------------------------ */
.md-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  background: var(--md-fill);
  color: var(--md-label-2);
}
.md-chip--amber { background: var(--md-amber-tint); color: var(--md-amber-deep); }
.md-chip--green { background: var(--md-green-tint); color: #1E7B3C; }
.md-chip--red   { background: var(--md-red-tint);   color: var(--md-red); }

/* --- iOS toggle switch ------------------------------------------- */
.md-switch {
  width: 51px; height: 31px; border-radius: var(--r-pill);
  background: rgba(120,120,128,0.16);
  position: relative; flex-shrink: 0; cursor: pointer;
  transition: background var(--dur-mid) var(--ease);
}
.md-switch[data-on="true"] { background: var(--md-green); }
.md-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: left var(--dur-mid) var(--ease);
}
.md-switch[data-on="true"]::after { left: 22px; }

/* --- Segmented control ------------------------------------------- */
.md-segmented {
  display: inline-flex;
  background: var(--md-fill);
  border-radius: var(--r-chip);
  padding: 2px;
  gap: 2px;
}
.md-segmented button {
  border: none; background: transparent; cursor: pointer;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500;
  color: var(--md-label); padding: 7px 16px; border-radius: 6px;
}
.md-segmented button[aria-selected="true"] {
  background: var(--md-elev); box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* --- Divider / hairline ------------------------------------------ */
.md-hr { border: 0; border-top: 1px solid var(--md-sep); margin: 0; }

/* --- Section framing (marketing) --------------------------------- */
.md-section {
  position: relative;
  padding: var(--s-10) var(--gutter-desktop);
}
.md-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-6);
  margin-bottom: var(--s-8);
}

/* --- Progress bar ------------------------------------------------- */
.md-bar { width: 100%; height: 8px; border-radius: var(--r-pill); background: var(--md-fill); overflow: hidden; }
.md-bar__fill { height: 100%; border-radius: var(--r-pill); background: var(--md-amber); transition: width var(--dur-slow) var(--ease); }

/* --- Focus -------------------------------------------------------- */
:where(a, button, input, textarea, select):focus-visible {
  outline: 3px solid var(--md-amber);
  outline-offset: 2px;
}
