/* GreenStory status page — mobile first, system fonts, light + dark. No framework. */

:root {
  color-scheme: light dark;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --text: #16211b;
  --muted: #5c6b63;
  --border: #d9e0dc;
  --link: #0f6b3f;
  --focus: #1d7fd6;

  --operational: #1e8f4e;
  --degraded: #c7900a;
  --partial_outage: #e06a1b;
  --major_outage: #cf2f2f;
  --maintenance: #2c6fd1;
  --unknown: #7a8580;

  --operational-bg: #e4f4ea;
  --degraded-bg: #fbf1d6;
  --partial_outage-bg: #fde6d7;
  --major_outage-bg: #fbe0e0;
  --maintenance-bg: #e0ebfb;
  --unknown-bg: #e9ecea;

  --radius: 10px;
  --gutter: 16px;
  --max: 960px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512;
    --surface: #182019;
    --text: #e6ede8;
    --muted: #9aa8a0;
    --border: #2b3630;
    --link: #6fd49a;
    --focus: #6db5ff;

    --operational: #3fcf7c;
    --degraded: #e9b949;
    --partial_outage: #f58a45;
    --major_outage: #ff6b6b;
    --maintenance: #6ea3ff;
    --unknown: #9aa8a0;

    --operational-bg: #15301f;
    --degraded-bg: #3a2f10;
    --partial_outage-bg: #3f2412;
    --major_outage-bg: #421b1b;
    --maintenance-bg: #16294a;
    --unknown-bg: #232a26;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--link); }
a:focus-visible, button:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.8rem; }
.nowrap { white-space: nowrap; }

.skip-link {
  position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 10;
}
.skip-link:focus { left: 8px; }

/* header / footer */
.site-header, main, .site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding-top: 16px; padding-bottom: 16px;
}
.brand img { display: block; height: 40px; width: auto; max-width: 100%; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.95rem; }
.site-footer { padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--border); margin-top: 32px; }

main > section { margin: 0 0 32px; }

/* overall banner */
.banner {
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  border-left: 8px solid var(--unknown);
  background: var(--unknown-bg);
}
.banner h1 { font-size: 1.5rem; }
.banner p { margin: 4px 0 0; }
.banner-operational { border-left-color: var(--operational); background: var(--operational-bg); }
.banner-degraded { border-left-color: var(--degraded); background: var(--degraded-bg); }
.banner-partial_outage { border-left-color: var(--partial_outage); background: var(--partial_outage-bg); }
.banner-major_outage { border-left-color: var(--major_outage); background: var(--major_outage-bg); }
.banner-maintenance { border-left-color: var(--maintenance); background: var(--maintenance-bg); }
.banner-unknown { border-left-color: var(--unknown); background: var(--unknown-bg); }

.notices { margin: 12px 0 32px; }
.notices:empty { margin: 0 0 32px; }
.notice {
  margin: 8px 0 0;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--unknown-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.95rem;
}

/* pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; white-space: nowrap;
  background: var(--unknown-bg); color: var(--text);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); flex: none; }
.pill-operational .dot { background: var(--operational); }
.pill-degraded .dot { background: var(--degraded); }
.pill-partial_outage .dot { background: var(--partial_outage); }
.pill-major_outage .dot { background: var(--major_outage); }
.pill-maintenance .dot { background: var(--maintenance); }
.pill-operational { background: var(--operational-bg); }
.pill-degraded { background: var(--degraded-bg); }
.pill-partial_outage { background: var(--partial_outage-bg); }
.pill-major_outage { background: var(--major_outage-bg); }
.pill-maintenance { background: var(--maintenance-bg); }

/* components */
.component-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.component { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.component:first-child { border-top: 0; }
.component-main { display: flex; flex-direction: column; min-width: 0; }
.component-name { font-weight: 600; }
.component-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* cards (incidents / maintenance) */
.card-list { display: grid; gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  border-left-width: 6px; padding: 16px;
}
.card-minor { border-left-color: var(--degraded); }
.card-major { border-left-color: var(--partial_outage); }
.card-critical { border-left-color: var(--major_outage); }
.card-maintenance { border-left-color: var(--maintenance); }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 6px; }
.sev { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; background: var(--unknown-bg); }
.sev-minor { background: var(--degraded-bg); }
.sev-major { background: var(--partial_outage-bg); }
.sev-critical { background: var(--major_outage-bg); }
.sev-maintenance { background: var(--maintenance-bg); }

.affected { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }

.timeline { list-style: none; margin: 8px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 10px 10px; }
.timeline li::before {
  content: ""; position: absolute; left: -20px; top: 7px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--muted); border: 2px solid var(--surface);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline-head { font-size: 0.9rem; }
.timeline-head time { color: var(--muted); }
.timeline p { margin: 2px 0 0; }

/* uptime */
.uptime-list { display: grid; gap: 10px; }
.uptime-row {
  display: grid; grid-template-columns: 1fr; gap: 6px 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px;
}
.uptime-name { font-weight: 600; }
.uptime-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.uptime-bar {
  border-radius: 4px; padding: 4px 6px; min-height: 36px; display: flex; flex-direction: column; justify-content: center;
  background: var(--unknown-bg); border-top: 4px solid var(--unknown); font-size: 0.8rem; line-height: 1.2;
}
.uptime-bar-pct { font-weight: 600; }
.level-operational { border-top-color: var(--operational); background: var(--operational-bg); }
.level-degraded { border-top-color: var(--degraded); background: var(--degraded-bg); }
.level-partial_outage { border-top-color: var(--partial_outage); background: var(--partial_outage-bg); }
.level-major_outage { border-top-color: var(--major_outage); background: var(--major_outage-bg); }
.level-none { color: var(--muted); }
.uptime-nums { display: flex; gap: 16px; font-size: 0.95rem; }

@media (min-width: 640px) {
  .uptime-row { grid-template-columns: 180px 1fr auto; }
  .banner h1 { font-size: 1.75rem; }
}

/* history */
.history-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.history-controls select {
  font: inherit; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  max-width: 100%;
}
.history-month { margin-bottom: 20px; }
.history-month h3 { margin-bottom: 8px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.history-table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 0.95rem; }
.history-table th, .history-table td { text-align: left; padding: 10px 12px; vertical-align: top; border-top: 1px solid var(--border); }
.history-table th { border-top: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.history-row.is-open td { border-bottom: 0; }
.history-detail td { border-top: 0; background: var(--bg); }
.history-detail-cell { padding-top: 0 !important; }

.linkish {
  font: inherit; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; text-decoration: underline;
}
.linkish[aria-expanded="true"]::before { content: "▾ "; }
.linkish[aria-expanded="false"]::before { content: "▸ "; }

@media (prefers-reduced-motion: no-preference) {
  .banner, .pill, .uptime-bar { transition: background-color 200ms ease, border-color 200ms ease; }
}
