/* ==========================================================================
   Arteria — Base
   Reset, typography defaults, layout primitives, device frame, utilities.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; }
p { margin: 0; }
hr { border: none; border-top: 1px solid var(--border); margin: 0; }

::selection { background: var(--brand); color: var(--text-on-brand); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }

:focus-visible {
  outline: 2px solid var(--live);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ---- Typography ---- */
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; text-wrap: balance; line-height: 1.08; }
.prose, p.body { text-wrap: pretty; line-height: 1.6; max-width: 66ch; }

.type-display-1 { font-family: var(--font-display); font-size: clamp(2.6rem, 2.2vw + 2rem, 4.75rem); font-weight: 600; letter-spacing: -0.03em; line-height: 1.02; }
.type-display-2 { font-family: var(--font-display); font-size: clamp(2rem, 1.6vw + 1.5rem, 3.25rem); font-weight: 600; letter-spacing: -0.025em; line-height: 1.05; }
.type-h1 { font-family: var(--font-display); font-size: clamp(1.6rem, 1vw + 1.3rem, 2.25rem); font-weight: 600; letter-spacing: -0.02em; }
.type-h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.015em; }
.type-h3 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.type-title { font-family: var(--font-body); font-size: 1.05rem; font-weight: 600; letter-spacing: -0.005em; }
.type-body { font-size: 0.975rem; line-height: 1.55; }
.type-body-sm { font-size: 0.875rem; line-height: 1.5; }
.type-label { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.01em; }
.type-caption { font-size: 0.75rem; color: var(--text-muted); }
.type-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.type-eyebrow { font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
em, .italic { font-family: var(--font-display); font-style: italic; }

/* ---- Layout primitives ---- */
.wrap { max-width: 1180px; margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 3rem); }
.section { padding-block: clamp(3.5rem, 8vw, 8rem); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-6); }
.spacer { flex: 1 1 auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: var(--z-toast);
  background: var(--brand); color: var(--text-on-brand); padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm); transition: top var(--dur-sm) var(--ease-out);
}
.skip-link:focus { top: var(--space-4); }

/* ---- Device frame (desktop preview chrome for /app screens) ----
   The stage must make the phone read as an unmistakable physical object —
   a visible edge and ambient glow — even when the screen inside it is dark.
   Without contrast here, dark app content visually "leaks" into the dark
   stage background and any UI near the bottom edge looks like it's
   spilling outside the device, even though it's correctly clipped. ---- */
.device-stage {
  height: 100vh; height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse 60% 50% at 50% 38%, oklch(0.22 0.02 32 / 0.55), transparent 70%),
    var(--stage-bg, var(--ink-0));
  padding: var(--space-10) var(--space-6);
  position: relative;
}
.device-scale-wrap { position: relative; flex-shrink: 0; }
.stage-chrome {
  position: fixed; top: 0; left: 0; right: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) clamp(1.25rem, 4vw, 2rem);
  background: color-mix(in oklch, var(--ink-0) 72%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.stage-chrome-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.stage-chrome-exit {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-full);
  background: var(--surface-3); border: 1px solid var(--border-strong);
  color: var(--text-secondary); font-size: 0.8125rem; font-weight: 600;
  text-decoration: none; transition: all var(--dur-sm) var(--ease-out);
}
.stage-chrome-exit:hover { background: var(--surface-raised); color: var(--text); border-color: var(--text-faint); }
.stage-chrome-exit svg { width: 15px; height: 15px; }
.device-frame {
  position: relative;
  width: 393px; height: 852px;
  border-radius: 55px;
  background: #050403;
  padding: 12px;
  box-shadow:
    0 30px 70px -15px oklch(0 0 0 / 0.65),
    0 10px 30px oklch(0 0 0 / 0.45),
    0 0 0 1px oklch(1 0 0 / 0.14),
    0 0 0 6px oklch(0.145 0.012 32 / 0.6),
    0 0 60px -10px oklch(0.585 0.155 32 / 0.18);
  flex-shrink: 0;
}
.device-screen {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 44px;
  overflow: hidden;
  background: var(--ink-0);
  display: flex; flex-direction: column;
}
.device-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 30px; background: #050403; border-radius: var(--radius-full);
  z-index: var(--z-sticky); display: flex; align-items: center; justify-content: flex-end; padding-right: 10px;
}
.device-notch::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #1a1a1a; box-shadow: inset 0 0 0 1px #333; }
.status-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px 2px; flex-shrink: 0; font-family: var(--font-mono);
  font-size: 0.75rem; font-weight: 500; color: var(--text); position: relative; z-index: 5;
}
.device-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
.device-scroll::-webkit-scrollbar { display: none; }

/* Room for the fixed .stage-chrome bar above the centered phone */
body:has(.device-stage) { padding-top: 0; }
.device-stage { padding-top: calc(var(--space-10) + 56px); }

@media (max-width: 500px) {
  .device-stage { padding: 0; align-items: stretch; }
  .device-frame { width: 100%; height: 100vh; height: 100dvh; border-radius: 0; padding: 0; box-shadow: none; }
  .device-screen { border-radius: 0; }
  .device-notch { display: none; }
  .stage-chrome { display: none; }
}

/* ---- Bottom tab bar (app) ---- */
.tab-bar {
  flex-shrink: 0; display: flex; align-items: stretch;
  background: color-mix(in oklch, var(--ink-1) 88%, transparent);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 8px);
  position: relative; z-index: var(--z-sticky);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 4px 8px; color: var(--text-faint); transition: color var(--dur-sm) var(--ease-out);
  cursor: pointer; min-height: 44px;
}
.tab-item svg { width: 22px; height: 22px; }
.tab-item span { font-size: 0.6875rem; font-weight: 500; }
.tab-item.is-active { color: var(--brand); }
.tab-item:active { transform: scale(0.95); }

/* ---- Top nav bar (app) ---- */
.nav-bar {
  flex-shrink: 0; display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); min-height: 52px;
  position: relative; z-index: var(--z-sticky);
}
.nav-bar.is-floating { position: absolute; top: 0; left: 0; right: 0; }
.nav-back {
  width: 40px; height: 40px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in oklch, var(--ink-2) 70%, transparent);
  backdrop-filter: blur(12px);
  transition: transform var(--dur-press) var(--ease-out);
  flex-shrink: 0;
}
.nav-back:active { transform: scale(0.92); }
.nav-bar-title { font-family: var(--font-body); font-weight: 600; font-size: 1rem; }

/* ---- Admin shell ---- */
.admin-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.admin-sidebar {
  background: var(--surface-2); border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-3); display: flex; flex-direction: column; gap: var(--space-1);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-main { min-width: 0; }
.admin-topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: var(--z-sticky);
}
.admin-content { padding: var(--space-6); max-width: 1360px; }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
}

/* ---- Utility ---- */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border); border: none; }
