/* ─────────────────────────────────────────────────────────────────────────
   PayHub brand override for the Upptime status-page Svelte SPA.

   Loaded AFTER the upstream theme files, so these win. The upstream
   build hashes class names per release, so this file only relies on
   structural and data-attribute selectors. The `data-ph-*` attributes
   are applied at runtime by the script in brand-patch.sh; runtime
   tagging means we don't depend on class hashes and survive upstream
   bumps with no edits.

   Theme model:
     - Default (no localStorage entry)  → "light" set by the early
       theme script in brand-patch.sh.
     - `:root[data-theme="light"]`      → light palette (this file's :root).
     - `:root[data-theme="dark"]`       → dark palette (override block).
     - Toggle's third option "system"   → removes data-theme and lets the
       prefers-color-scheme media query take over.
   ───────────────────────────────────────────────────────────────────────── */

/* Self-hosted Somar Sans. Files live in /fonts/ on the deployed site;
   the brand-patch.sh copies them into the export tree at build time.
   Hosting locally avoids the cross-site SameSite=Lax cookie warning
   from Fontshare's CSS endpoint. */
@font-face {
  font-family: "Somar Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/somar-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "Somar Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/somar-sans-500.woff2") format("woff2");
}
@font-face {
  font-family: "Somar Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/somar-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "Somar Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/somar-sans-700.woff2") format("woff2");
}
@font-face {
  font-family: "Somar Sans";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/fonts/somar-sans-800.woff2") format("woff2");
}

/* ─── Theme tokens — light ────────────────────────────────────────────── */
:root {
  --ph-accent: #F39200;
  --ph-accent-deep: #C97400;
  --ph-accent-soft: rgba(243, 146, 0, 0.10);
  --ph-accent-tint: rgba(243, 146, 0, 0.04);

  --ph-text: #15110b;
  --ph-text-muted: #6e6353;
  --ph-text-faint: #9c9082;

  --ph-bg: #fbf7f0;             /* warm parchment */
  --ph-bg-top: #fff8ec;         /* warmer at the top — subtle gradient */
  --ph-card: #ffffff;
  --ph-card-elev: #ffffff;
  --ph-border: #ebe5d8;
  --ph-border-soft: #f3eee3;

  --ph-up: #2bb673;
  --ph-down: #e85a4f;
  --ph-degraded: #f0a82e;

  --ph-shadow-card: 0 1px 2px rgba(40, 22, 0, 0.04), 0 8px 24px rgba(40, 22, 0, 0.04);
  --ph-shadow-hover: 0 2px 4px rgba(40, 22, 0, 0.05), 0 14px 32px rgba(40, 22, 0, 0.08);
  --ph-shadow-pill: 0 1px 3px rgba(243, 146, 0, 0.35);

  /* Upstream Upptime variable overrides */
  --body-background-color: var(--ph-bg);
  --body-text-color: var(--ph-text);
  --card-background-color: var(--ph-card);
  --card-border-color: transparent;
  --nav-background-color: rgba(251, 247, 240, 0.78);
  --nav-border-bottom-color: var(--ph-border);
  --nav-current-border-bottom-color: var(--ph-accent);
  --error-button-background-color: var(--ph-accent);
  --error-button-border-color: var(--ph-accent-deep);
  --error-button-color: #ffffff;
  --submit-button-background-color: var(--ph-accent);
  --submit-button-border-color: var(--ph-accent-deep);
  --submit-button-color: #ffffff;
}

/* ─── Theme tokens — dark ─────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --ph-accent: #FFA51F;
  --ph-accent-deep: #D78315;
  --ph-accent-soft: rgba(255, 165, 31, 0.14);
  --ph-accent-tint: rgba(255, 165, 31, 0.06);

  --ph-text: #f4ecdc;
  --ph-text-muted: #a89a82;
  --ph-text-faint: #6e6353;

  --ph-bg: #100d09;
  --ph-bg-top: #1a1410;
  --ph-card: #1c1813;
  --ph-card-elev: #221d17;
  --ph-border: #2c241a;
  --ph-border-soft: #221c14;

  --ph-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.5);
  --ph-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.5), 0 16px 36px rgba(0, 0, 0, 0.6);
  --ph-shadow-pill: 0 1px 3px rgba(255, 165, 31, 0.35);

  --body-background-color: var(--ph-bg);
  --body-text-color: var(--ph-text);
  --card-background-color: var(--ph-card);
  --card-border-color: transparent;
  --nav-background-color: rgba(28, 24, 19, 0.78);
  --nav-border-bottom-color: var(--ph-border);
  --nav-current-border-bottom-color: var(--ph-accent);
}

/* Auto-OS dark only when user has explicitly chosen "system" — the
   early theme script defaults new visitors to "light", so this path
   only fires for users who opted into "system" via the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --ph-accent: #FFA51F;
    --ph-accent-deep: #D78315;
    --ph-accent-soft: rgba(255, 165, 31, 0.14);
    --ph-accent-tint: rgba(255, 165, 31, 0.06);
    --ph-text: #f4ecdc;
    --ph-text-muted: #a89a82;
    --ph-text-faint: #6e6353;
    --ph-bg: #100d09;
    --ph-bg-top: #1a1410;
    --ph-card: #1c1813;
    --ph-card-elev: #221d17;
    --ph-border: #2c241a;
    --ph-border-soft: #221c14;
    --ph-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.5);
    --ph-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.5), 0 16px 36px rgba(0, 0, 0, 0.6);
    --ph-shadow-pill: 0 1px 3px rgba(255, 165, 31, 0.35);
    --body-background-color: var(--ph-bg);
    --body-text-color: var(--ph-text);
    --card-background-color: var(--ph-card);
    --card-border-color: transparent;
    --nav-background-color: rgba(28, 24, 19, 0.78);
    --nav-border-bottom-color: var(--ph-border);
  }
}

/* ─── Base / typography ───────────────────────────────────────────────── */
html { background-color: var(--ph-bg); }
body {
  margin: 0;
  font-family: "Somar Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: -0.005em;
  font-feature-settings: "ss01", "cv11", "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--ph-text);
  /* Subtle warm radial wash at the top — adds depth, stays out of content's way. */
  background:
    radial-gradient(ellipse 120% 600px at 50% -100px,
      var(--ph-bg-top) 0%,
      transparent 65%),
    var(--ph-bg);
  padding-bottom: 4rem;
  min-height: 100vh;
}
@media (min-width: 400px) { body { font-size: 16px; } }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em 0;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--ph-text);
}
h1 { font-size: 2.75rem; font-weight: 800; letter-spacing: -0.035em; }
h2 { font-size: 1.625rem; letter-spacing: -0.02em; margin-top: 1.5rem; }
h3 { font-size: 1.125rem; }
p  { color: var(--ph-text); }

a  { color: inherit; text-decoration: none; transition: color 140ms ease; }
a:hover { color: var(--ph-accent-deep); }

/* ─── Container ───────────────────────────────────────────────────────── */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1.5rem;
  box-sizing: border-box;
}
@media (min-width: 900px) {
  .container { max-width: 920px; padding: 0 2rem; }
}

/* ─── Nav ─────────────────────────────────────────────────────────────── */
nav {
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}
nav .container img {
  width: 28px; height: 28px;
  object-fit: contain;
  border-radius: 7px;
}

/* ─── Theme toggle button (injected into nav <ul>) ────────────────────── */
.ph-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--ph-border);
  background: transparent;
  border-radius: 9px;
  color: var(--ph-text-muted);
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 120ms ease;
}
.ph-theme-toggle:hover {
  color: var(--ph-accent);
  border-color: var(--ph-accent);
  background: var(--ph-accent-soft);
}
.ph-theme-toggle:active { transform: scale(0.96); }
.ph-theme-toggle:focus-visible {
  outline: 2px solid var(--ph-accent);
  outline-offset: 2px;
}
.ph-theme-toggle svg { width: 18px; height: 18px; display: block; }
nav ul li.ph-theme-toggle-item {
  list-style: none;
  display: inline-flex;
  align-items: center;
}

/* ─── Service cards (stable structural selector) ──────────────────────── */
main section > div {
  border-radius: 14px !important;
  border: 0 !important;
  background-color: var(--ph-card) !important;
  box-shadow: var(--ph-shadow-card);
  padding: 1.25rem 1.5rem !important;
  margin-bottom: 0.875rem !important;
  transition: transform 200ms cubic-bezier(.2,.7,.2,1),
              box-shadow 200ms ease,
              background-color 200ms ease;
}
main section > div:hover {
  transform: translateY(-2px);
  box-shadow: var(--ph-shadow-hover);
  background-color: var(--ph-card-elev) !important;
}

/* Up/down/degraded status pills — modernized but still semantic */
main section > div .tag,
main section > div [class*="up"],
main section > div [class*="down"],
main section > div [class*="degraded"] {
  /* The upstream `.tag` ish elements vary; the most reliable thing we
     can do is leave their colors alone (kept as universal traffic
     lights) and just round + space them via the structural selector
     below. */
}
/* The tag is typically the last small <span> in the card row — give it
   pill rounding without overriding upstream colours. */
main section > div span[class] {
  border-radius: 999px !important;
}

/* ─── Time-range segmented control ────────────────────────────────────── */
/* The brand-patch JS tags the <form> that holds the 5 radio+label
   pairs with [data-ph-range-tabs]. Active state is the native
   :checked — no JS sync needed. */
[data-ph-range-tabs] {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--ph-accent-soft);
  border-radius: 999px;
  padding: 4px;
  margin: 0.25rem 0 1.25rem 0;
  border: 0 !important;
}
[data-ph-range-tabs] > div {
  display: inline-flex;
  position: relative;
  margin: 0 !important;
  padding: 0 !important;
}
[data-ph-range-tabs] input[type="radio"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  /* keep above the label for click handling */
  z-index: 1;
}
[data-ph-range-tabs] label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--ph-text-muted);
  background: transparent;
  transition: background 160ms ease, color 160ms ease, transform 100ms ease;
  user-select: none;
  white-space: nowrap;
}
[data-ph-range-tabs] label:hover { color: var(--ph-text); background: var(--ph-accent-tint); }
[data-ph-range-tabs] input[type="radio"]:checked + label {
  background: var(--ph-accent);
  color: #ffffff;
  box-shadow: var(--ph-shadow-pill);
}
[data-ph-range-tabs] input[type="radio"]:focus-visible + label {
  outline: 2px solid var(--ph-accent);
  outline-offset: 2px;
}
[data-ph-range-tabs] input[type="radio"]:active + label { transform: scale(0.97); }

/* ─── Hero / intro ────────────────────────────────────────────────────── */
main > section:first-of-type,
main > h1:first-child,
main > div:first-child {
  margin-top: 1rem;
}
/* h1 inside <main> gets a touch more air to feel like a hero, not a list item */
main h1 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
main h1 + p { color: var(--ph-text-muted); max-width: 64ch; }

/* ─── Footer ──────────────────────────────────────────────────────────── */
footer {
  color: var(--ph-text-faint);
  font-size: 0.85rem;
  padding-top: 2rem;
}
footer a {
  color: var(--ph-text-muted);
  border-bottom: 1px dotted var(--ph-border);
}
footer a:hover { color: var(--ph-accent-deep); border-bottom-color: var(--ph-accent); }

/* ─── Small refinements ───────────────────────────────────────────────── */
::selection {
  background-color: var(--ph-accent);
  color: #ffffff;
}
