/* Frontier Status, public page.
   Every colour below is a Frontier TextileCloud token (packages/tailwindcss/colors.ts):
   primary, grey, cyan, yellow, red, white, black. No other colours, no web fonts,
   no external requests. Text pairs meet WCAG AA (4.5:1) in light and dark.

   State colours live in one set of custom properties per state (--s-*), applied by
   [data-state], so the banner, the row tag and the icon always agree. */

:root {
  color-scheme: light dark;

  --bg: #FAFCFC;            /* white */
  --surface: #FFFFFF;       /* grey-0 */
  --subtle: #F3F3F3;        /* grey-50 */
  --text: #2B2C2C;          /* black */
  --muted: #5A5B5B;         /* grey-700, 6.6:1 on bg */
  --border: #DEDEDE;        /* grey-100 */
  --border-strong: #C9C9C9; /* grey-200 */
  --brand: #03393E;         /* primary-900 */
  --brand-mark: #20A17A;    /* primary-500 */
  --link: #0A6665;          /* primary-700, 6.4:1 */
  --link-hover: #074E54;    /* primary-800 */
  --focus: #0F7F73;         /* primary-600 */
  --shadow: 0 1px 2px rgba(19, 20, 20, 0.06);
  --tip-bg: #131414;
  --tip-ink: #F3F3F3;
  --tip-line: #424343;

  /* 90 day bar levels. A worse day is also a shorter cell. */
  --ok: #20A17A;            /* primary-500 */
  --minor: #E9B62E;         /* yellow-400 */
  --low: #A16438;           /* brown-500 */
  --bad: #AE001F;           /* red-600 */
  --none: #C9C9C9;          /* grey-200 */
  --maint: #098DAF;         /* cyan-600 */
  --hatch: rgba(250, 252, 252, 0.7); /* overlayinverse-70 */

  /* State sets: tint, line, ink (text on tint), icon, glyph (on icon). */
  --op-bg: #E9F8F3; --op-line: #71DABB; --op-ink: #074E54; --op-icon: #0F7F73; --op-glyph: #FFFFFF;
  --mt-bg: #E6F9FF; --mt-line: #8ADDF4; --mt-ink: #025D75; --mt-icon: #057693; --mt-glyph: #FFFFFF;
  --dg-bg: #FFF8E6; --dg-line: #F5CA5C; --dg-ink: #5D4300; --dg-icon: #E9B62E; --dg-glyph: #2B2C2C;
  --po-bg: #FDE7DA; --po-line: #F48A93; --po-ink: #740012; --po-icon: #E95C6D; --po-glyph: #131414;
  --mo-bg: #FFE6E6; --mo-line: #F48A93; --mo-ink: #920018; --mo-icon: #C90027; --mo-glyph: #FFFFFF;
  --uk-bg: #F3F3F3; --uk-line: #C9C9C9; --uk-ink: #424343; --uk-icon: #717272; --uk-glyph: #FFFFFF;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131414;            /* grey-950 */
    --surface: #2B2C2C;       /* grey-900 */
    --subtle: #303030;        /* grey-850 */
    --text: #F3F3F3;          /* grey-50 */
    --muted: #B3B4B4;         /* grey-300, 6.5:1 on surface */
    --border: #424343;        /* grey-800 */
    --border-strong: #5A5B5B; /* grey-700 */
    --brand: #FAFCFC;
    --brand-mark: #3EC39B;    /* primary-300 */
    --link: #71DABB;          /* primary-200 */
    --link-hover: #CFF6EB;    /* primary-100 */
    --focus: #3EC39B;
    --shadow: none;
    --tip-bg: #F3F3F3;
    --tip-ink: #2B2C2C;
    --tip-line: #C9C9C9;

    --ok: #21B185;            /* primary-400 */
    --minor: #E9B62E;         /* yellow-400 */
    --low: #B48360;           /* brown-400 */
    --bad: #DB2E49;           /* red-400 */
    --none: #454545;          /* grey-750 */
    --maint: #32B9DC;         /* cyan-400 */
    --hatch: rgba(19, 20, 20, 0.55); /* overlaymain-50 */

    --op-bg: #03393E; --op-line: #0A6665; --op-ink: #CFF6EB; --op-icon: #3EC39B; --op-glyph: #131414;
    --mt-bg: #004557; --mt-line: #057693; --mt-ink: #B8ECFB; --mt-icon: #32B9DC; --mt-glyph: #131414;
    --dg-bg: #5D4300; --dg-line: #9D7300; --dg-ink: #FFEBB8; --dg-icon: #E9B62E; --dg-glyph: #131414;
    --po-bg: #740012; --po-line: #AE001F; --po-ink: #FDE7DA; --po-icon: #F48A93; --po-glyph: #131414;
    --mo-bg: #56000C; --mo-line: #920018; --mo-ink: #FFE6E6; --mo-icon: #DB2E49; --mo-glyph: #131414;
    --uk-bg: #303030; --uk-line: #5A5B5B; --uk-ink: #DEDEDE; --uk-icon: #9E9F9F; --uk-glyph: #131414;
  }
}

/* One state set per data-state value. Unknown is the default: never green. */
[data-state] {
  --s-bg: var(--uk-bg); --s-line: var(--uk-line); --s-ink: var(--uk-ink);
  --s-icon: var(--uk-icon); --s-glyph: var(--uk-glyph); --s-mark: "?";
}
[data-state="operational"] {
  --s-bg: var(--op-bg); --s-line: var(--op-line); --s-ink: var(--op-ink);
  --s-icon: var(--op-icon); --s-glyph: var(--op-glyph); --s-mark: "\2713";
}
[data-state="maintenance"] {
  --s-bg: var(--mt-bg); --s-line: var(--mt-line); --s-ink: var(--mt-ink);
  --s-icon: var(--mt-icon); --s-glyph: var(--mt-glyph); --s-mark: "i";
}
[data-state="degraded"] {
  --s-bg: var(--dg-bg); --s-line: var(--dg-line); --s-ink: var(--dg-ink);
  --s-icon: var(--dg-icon); --s-glyph: var(--dg-glyph); --s-mark: "!";
}
[data-state="partial_outage"] {
  --s-bg: var(--po-bg); --s-line: var(--po-line); --s-ink: var(--po-ink);
  --s-icon: var(--po-icon); --s-glyph: var(--po-glyph); --s-mark: "!";
}
[data-state="major_outage"] {
  --s-bg: var(--mo-bg); --s-line: var(--mo-line); --s-ink: var(--mo-ink);
  --s-icon: var(--mo-icon); --s-glyph: var(--mo-glyph); --s-mark: "\00D7";
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

header, main, footer {
  width: 100%;
  max-width: 912px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

/* Header */
header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 28px;
  padding-bottom: 28px;
}
.brand { color: var(--brand); display: flex; border-radius: 4px; }
.brand svg { height: 24px; width: auto; display: block; }
.brand .mark { color: var(--brand-mark); }
.product {
  font-size: 17px;
  font-weight: 600;
  line-height: 24px;
  color: var(--muted);
  padding-left: 14px;
  border-left: 1px solid var(--border-strong);
}
a.product, a.product:hover { color: var(--muted); text-decoration: none; }

/* Sections */
section { margin-top: 40px; }
h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.005em;
}
section > h2 { margin-bottom: 12px; }

/* Overall banner: tinted card, icon with a glyph so the state never depends on colour alone. */
.banner {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin: 0;
  min-height: 96px;
  padding: 28px 28px 28px 88px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 12px;
  background: var(--s-bg);
  border: 1px solid var(--s-line);
  border-radius: 12px;
  color: var(--text);
}
/* Icon: a rounded square like the Frontier mark, with the state glyph. */
.banner::before {
  content: var(--s-mark);
  content: var(--s-mark) / "";
  position: absolute;
  z-index: 1;
  left: 28px;
  top: 50%;
  width: 40px;
  height: 40px;
  margin-top: -20px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--s-icon);
  color: var(--s-glyph);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}
/* Texture: the half-square triangles of the Frontier mark, rising as a staircase
   from the bottom right corner in the state colour. */
.banner::after {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(46%, 360px);
  background: linear-gradient(135deg, transparent 0 50%, var(--s-line) 50% 100%) right bottom / 16px 16px;
  -webkit-mask-image: linear-gradient(to top left, #000 0 18%, transparent 62%);
  mask-image: linear-gradient(to top left, #000 0 18%, transparent 62%);
  opacity: 0.9;
  pointer-events: none;
}
.banner > * { position: relative; z-index: 1; }
.banner strong {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--s-ink);
}
@media (prefers-color-scheme: dark) {
  .banner > :not(strong) { color: var(--text); }
}
.loading .banner { opacity: 0.7; }

/* Services */
.section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 20px;
  margin-bottom: 12px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 16px;
  color: var(--muted);
}
.legend li { display: flex; align-items: flex-end; gap: 6px; }
/* Full height in the legend, so every swatch is big enough to read its colour. */
.legend .day { --full: 14px; --h: 1 !important; width: 7px; flex: none; border-radius: 2px; }

.components {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
/* Stale data: the whole list loses its colour, so nothing reads as "green". */
.components.stale { filter: grayscale(1); }
.component { padding: 18px 24px 16px; }
.component + .component { border-top: 1px solid var(--border); }

.row-head, .row-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.name { font-weight: 600; font-size: 15px; min-width: 0; }

/* Current state: a tag in the product style. */
.state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 2px 10px 2px 8px;
  border-radius: 999px;
  background: var(--s-bg);
  color: var(--s-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
  white-space: nowrap;
}
.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--s-icon);
}

.bar {
  --full: 32px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: var(--full);
  margin: 14px 0 8px;
  border-radius: 3px;
  cursor: crosshair;
  /* A finger sliding sideways reads the days; up and down still scrolls the page. */
  touch-action: pan-y;
}
.bar:focus-visible { outline-offset: 4px; }
/* A worse day is also a shorter bar, so the chart does not depend on telling colours apart. */
.day {
  flex: 1;
  min-width: 0;
  height: calc(var(--full) * var(--h, 1));
  border-radius: 2px;
  background-color: var(--none);
}
.day[data-level="ok"] { background-color: var(--ok); }
.day[data-level="minor"] { background-color: var(--minor); --h: 0.75; }
.day[data-level="low"] { background-color: var(--low); --h: 0.5; }
.day[data-level="bad"] { background-color: var(--bad); --h: 0.3; }
.day[data-level="none"] { background-color: var(--none); }
.day[data-request] {
  background-image: repeating-linear-gradient(135deg, transparent 0 2px, var(--hatch) 2px 4px);
}
.day.on { outline: 2px solid var(--text); outline-offset: 1px; }

.row-foot {
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.row-foot > :first-child, .row-foot > :last-child { flex: none; }
.uptime { flex: 1; text-align: center; color: var(--text); font-weight: 500; }

.note {
  max-width: 72ch;
  margin: 12px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

/* Incidents and maintenance */
.incident {
  margin-top: 12px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.items > .incident:first-child { margin-top: 0; }
.incident.active { border-color: var(--mo-line); }
.incident.scheduled { border-color: var(--mt-line); }
.incident h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.incident h3::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}
.incident.active h3::before { background: var(--bad); box-shadow: 0 0 0 4px var(--mo-bg); }
.incident.scheduled h3::before { background: var(--maint); box-shadow: 0 0 0 4px var(--mt-bg); }
.incident p { margin: 4px 0 0; overflow-wrap: anywhere; }
.incident .meta { margin-top: 4px; padding-left: 20px; }
.incident .meta, .incident time {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.incident > p:last-child:not(.meta) { margin-top: 16px; padding-left: 20px; }

/* Updates read as a timeline, newest first. */
.updates {
  list-style: none;
  margin: 16px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
}
.updates li { position: relative; padding: 0 0 16px 20px; }
.updates li:last-child { padding-bottom: 0; }
.updates li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
}
.updates li::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 21px;
  bottom: 2px;
  width: 2px;
  border-radius: 1px;
  background: var(--border);
}
.updates li:last-child::after { display: none; }
.incident.active .updates li:first-child::before { border-color: var(--bad); background: var(--bad); }
.incident.scheduled .updates li:first-child::before { border-color: var(--maint); background: var(--maint); }
.updates p { margin: 0; white-space: pre-line; }
.updates strong { font-weight: 600; }
.updates time { display: block; margin-top: 2px; }

.empty {
  margin: 0;
  padding: 16px 20px;
  font-size: 14px;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}

/* Footer */
footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 56px;
  padding-top: 20px;
  padding-bottom: 48px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Day tooltip */
.tip {
  position: fixed;
  z-index: 10;
  max-width: 260px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--tip-bg);
  color: var(--tip-ink);
  border: 1px solid var(--tip-line);
  box-shadow: 0 4px 16px rgba(19, 20, 20, 0.2);
  font-size: 13px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.tip > * { display: block; }
.tip > :first-child { font-weight: 600; margin-bottom: 2px; }

/* Small screens: 375 px with no sideways scroll. */
@media (max-width: 600px) {
  body { font-size: 15px; }
  header, main, footer { padding-left: 16px; padding-right: 16px; }
  header { padding-top: 20px; padding-bottom: 20px; }
  .brand svg { height: 22px; }
  .product { font-size: 16px; line-height: 22px; }
  section { margin-top: 32px; }
  .banner { padding: 18px 16px 18px 64px; min-height: 0; border-radius: 10px; }
  .banner::before { left: 16px; top: 18px; margin-top: 0; width: 34px; height: 34px; border-radius: 9px; font-size: 19px; }
  .banner::after { width: 55%; background-size: 12px 12px; opacity: 0.7; }
  .banner strong { font-size: 20px; }
  .legend { gap: 6px 12px; font-size: 12px; }
  .components, .incident, .empty { border-radius: 10px; }
  .component { padding: 14px 14px 12px; }
  .name { font-size: 14px; }
  .state { font-size: 12px; padding: 1px 8px 1px 7px; }
  .bar { --full: 36px; gap: 1px; margin-top: 12px; }
  .day { border-radius: 1px; }
  .row-foot { font-size: 12px; gap: 8px; }
  .incident { padding: 16px; }
  .incident .meta, .incident > p:last-child:not(.meta) { padding-left: 0; }
  footer { flex-direction: column; margin-top: 40px; }
}

/* Windows high contrast: keep the chart and status icons readable. */
@media (forced-colors: active) {
  .day, .legend .day, .dot, .banner::before { forced-color-adjust: none; }
  .banner::after { display: none; }
  .banner, .components, .incident, .state { border: 1px solid CanvasText; }
}

@media print {
  .tip { display: none !important; }
  .components, .incident, .banner { box-shadow: none; break-inside: avoid; }
  .day { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
