/* ============================================================
   REV.health — 2-tab launcher v1
   Brand: navy #0B2540 · card #12324F · teal #0A8A83 · mint #02C39A
          paper #F7F9F8 · ice #DDEBE9 · muted #5B7083 · ink #122433
   CSS-first. Tabs are real <button role="tab"> panels toggled by JS.
   ============================================================ */

:root {
  --navy: #0B2540;
  --navy-2: #0E2C4B;
  --card: #12324F;
  --card-2: #16395A;
  --teal: #0A8A83;
  --mint: #02C39A;
  --mint-soft: #E6F7F2;
  --paper: #F7F9F8;
  --ice: #DDEBE9;
  --muted: #5B7083;
  --ink: #122433;
  --line: rgba(11, 37, 64, 0.10);
  --line-dark: rgba(221, 235, 233, 0.14);
  --shadow-lg: 0 30px 70px -28px rgba(11, 37, 64, 0.45);
  --shadow-md: 0 16px 40px -20px rgba(11, 37, 64, 0.30);
  --radius: 14px;
  --radius-lg: 20px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "Fira Code", monospace;
  --gutter: clamp(20px, 4vw, 64px);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--navy); color: #fff; padding: .6rem 1rem; border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--ice);
  color: var(--navy);
  padding: .12rem .4rem;
  border-radius: 5px;
}

/* ============ Topbar + tabs ============ */
.topbar {
  display: flex; align-items: center; gap: 1.4rem;
  padding: .8rem var(--gutter);
  background: var(--navy);
  color: #eaf2ff;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 8px 24px -16px rgba(11, 37, 64, 0.6);
  flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: .4rem;
  text-decoration: none; color: #eaf2ff;
  font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em;
}
.brand-word { color: #fff; }
.brand-sep { color: var(--mint); opacity: .8; }
.brand-page { color: var(--mint); font-weight: 600; font-size: .9rem; letter-spacing: .04em; text-transform: uppercase; }

.tabs {
  display: inline-flex; gap: .25rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line-dark);
  border-radius: 10px;
  padding: .25rem;
  margin-left: auto;
}
.tab {
  appearance: none;
  border: none; background: transparent;
  color: #b9c8da; font-family: inherit; font-weight: 600; font-size: .92rem;
  padding: .5rem 1.1rem; border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab:hover { color: #fff; }
.tab.active {
  background: linear-gradient(135deg, var(--mint), #4fd6b0);
  color: var(--navy);
}
.tab:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }

/* ============ Main / panels ============ */
.main { padding: clamp(28px, 4vw, 56px) var(--gutter) 80px; max-width: 1320px; margin: 0 auto; }
.panel { animation: fade .25s ease; }
.panel[hidden] { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } }

/* ============ Pitch hero ============ */
.pitch-hero { margin-bottom: 2.4rem; max-width: 760px; }
.eyebrow {
  display: inline-block; font-size: .76rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--teal); margin-bottom: .6rem;
}
.pitch-hero h1 {
  margin: 0 0 .8rem; font-size: clamp(28px, 4vw, 44px); line-height: 1.1;
  letter-spacing: -0.02em; color: var(--navy); font-weight: 900;
}
.pitch-hero .lede { margin: 0; font-size: 1.1rem; color: var(--muted); line-height: 1.6; }

.section-title {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--teal); font-weight: 700; margin: 0 0 1rem;
}

/* ============ Artifact cards ============ */
.artifacts { margin-bottom: 3rem; }
.artifact-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 1rem;
}
.artifact-card {
  display: flex; gap: 1rem; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; text-decoration: none; color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  box-shadow: 0 6px 18px -12px rgba(11, 37, 64, 0.15);
}
.artifact-card:hover {
  border-color: var(--mint); transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.artifact-card.primary {
  background: linear-gradient(135deg, var(--navy), var(--card));
  border-color: var(--mint); color: #eaf2ff;
}
.artifact-card.primary h3, .artifact-card.primary .artifact-link { color: #fff; }
.artifact-card.primary .artifact-link { color: var(--mint); }
.artifact-card.primary p { color: #c8d6e6; }
.artifact-icon {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1.4rem;
  background: var(--mint-soft); color: var(--teal);
}
.artifact-card.primary .artifact-icon { background: rgba(5, 195, 154, 0.18); }
.artifact-body { flex: 1; min-width: 0; }
.artifact-body h3 { margin: 0 0 .35rem; font-size: 1.1rem; color: var(--navy); }
.artifact-body p { margin: 0 0 .55rem; font-size: .9rem; color: var(--muted); line-height: 1.5; }
.artifact-link {
  font-size: .82rem; font-weight: 600; color: var(--teal);
  font-family: var(--mono); word-break: break-all;
}

/* ============ Mermaid diagram block ============ */
.diagram-block {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.6rem clamp(1rem, 3vw, 2.4rem) 2rem;
  box-shadow: var(--shadow-md);
}
.diagram-blurb { color: var(--muted); font-size: .98rem; max-width: 760px; margin: 0 0 1.4rem; }
.mermaid {
  display: flex; justify-content: center; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; min-height: 320px; overflow-x: auto;
}
.mermaid svg { max-width: 100%; height: auto; }
.mermaid.error { color: #b3261e; font-family: var(--mono); font-size: .85rem; padding: 1.4rem; }
.noscript-fallback { color: var(--muted); font-size: .9rem; }

/* ============ All Sites controls ============ */
.sites-controls {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center;
  margin-bottom: 1.6rem;
}
.search-wrap {
  position: relative; flex: 1 1 320px; min-width: 240px;
}
.search-wrap input {
  width: 100%; padding: .7rem 2.6rem .7rem 2.4rem;
  font-family: inherit; font-size: .95rem;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(2, 195, 154, 0.18); }
.search-icon {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .95rem; pointer-events: none;
}
.clear-btn {
  position: absolute; right: .55rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); font-size: 1.3rem;
  cursor: pointer; padding: .1rem .45rem; border-radius: 6px; line-height: 1;
}
.clear-btn:hover { color: var(--navy); background: var(--ice); }

.filter-pills { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.pbtn {
  font-family: inherit; font-size: .82rem; font-weight: 600;
  padding: .42rem .85rem; border-radius: 8px;
  border: 1px solid var(--line); color: var(--muted);
  background: #fff; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.pbtn:hover { border-color: var(--mint); color: var(--navy); }
.pbtn.active {
  border-color: var(--mint); color: var(--navy);
  background: var(--mint-soft);
}

.search-count {
  font-size: .82rem; color: var(--muted); min-width: 9rem; text-align: right;
  white-space: nowrap;
}

/* ============ Site cards ============ */
.site-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .9rem;
}
.site-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .5rem;
  transition: border-color .15s, transform .15s;
}
.site-card:hover { border-color: var(--mint); transform: translateY(-2px); }
.site-card[hidden] { display: none; }
.site-card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.site-card h3 { margin: 0; font-size: 1.02rem; color: var(--navy); }
.site-card .desc { color: var(--muted); font-size: .85rem; line-height: 1.45; margin: 0; flex: 1; }
.site-card .links { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .2rem; }
.site-card .meta { font-size: .72rem; color: var(--muted); font-family: var(--mono); word-break: break-all; }
.site-card .url a { color: var(--teal); text-decoration: none; font-family: var(--mono); font-size: .76rem; word-break: break-all; }
.site-card .url a:hover { text-decoration: underline; }
.btn {
  text-decoration: none; font-size: .8rem; font-weight: 600; padding: .4rem .75rem;
  border-radius: 8px; border: 1px solid var(--line); color: var(--navy);
  display: inline-flex; align-items: center; gap: .3rem; background: var(--paper);
}
.btn:hover { border-color: var(--mint); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--card); border-color: var(--mint); }

.type-badge {
  display: inline-block; font-size: .66rem; font-weight: 700; padding: .15rem .45rem;
  border-radius: 4px; background: var(--ice); color: var(--muted);
  border: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.type-badge.current { color: var(--teal); border-color: rgba(2, 195, 154, 0.45); background: var(--mint-soft); }
.type-badge.new { color: #b9770c; border-color: rgba(245, 185, 66, 0.45); background: #fff4dc; }
.type-badge.legacy { color: var(--muted); background: #eef2f5; }

.empty-state {
  text-align: center; color: var(--muted); padding: 2.4rem 1rem; font-size: .95rem;
  border: 1px dashed var(--line); border-radius: var(--radius); background: #fff;
}

/* ============ Redeploy table ============ */
.redeploy {
  margin-top: 2.6rem; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.4rem clamp(1rem, 3vw, 2rem);
  box-shadow: var(--shadow-md);
}
.redeploy-note { color: var(--muted); font-size: .9rem; margin: .3rem 0 1.1rem; line-height: 1.55; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { text-align: left; padding: .55rem .65rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .7rem; font-weight: 700; }
td.dir, td.id { font-family: var(--mono); font-size: .76rem; color: var(--muted); word-break: break-all; }
tr[hidden] { display: none; }

/* ============ Footer ============ */
.footer {
  border-top: 1px solid var(--line);
  padding: 1.2rem var(--gutter); color: var(--muted); font-size: .82rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: #fff;
}
.footer-note { color: var(--muted); }

/* ============ Mobile ============ */
@media (max-width: 640px) {
  .topbar { gap: .8rem; padding: .7rem 1rem; }
  .tabs { width: 100%; margin-left: 0; }
  .tab { flex: 1; text-align: center; }
  .main { padding: 24px 1rem 60px; }
  .sites-controls { flex-direction: column; align-items: stretch; }
  .search-count { text-align: left; }
  .filter-pills { width: 100%; }
  .pbtn { flex: 1; text-align: center; }
  .artifact-grid, .site-grid { grid-template-columns: 1fr; }
  .footer { flex-direction: column; }
}
