/* Base — reset, typography, app shell, splash, skeletons (SPEC §9, §17) */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-md);
  line-height: var(--lh);
  /* Western digits always (SPEC 2.4): lining + tabular, no locale digit substitution */
  font-variant-numeric: lining-nums tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.4; margin: 0 0 var(--sp-3); color: var(--primary-dark); }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--primary-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }
.main > .page-head + .page-head-body { margin-top: -36px; }
img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
/* Latin runs here are ids, e-mails and operation names: one long unbroken token. Without a break rule
   the row it sits in widens the whole page sideways — which is what the audit log did once it had rows. */
.latin { font-family: var(--font-latin); direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere; }
.num { font-variant-numeric: lining-nums tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* touch behaviour: no double-tap zoom delay, no text selection on controls, no long-press callout */
a, button, [role="button"], .cell, .nav-item, .list-item, .day, .event-chip, .tab { touch-action: manipulation; }
.cell, .nav-item, .btn, .day, .tile, .tab, .date-chip { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* focus — visible ring for keyboard users (WCAG 2.4.7); gold on primary surfaces so it never disappears */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); box-shadow: 0 0 0 2px var(--surface); }
.topbar :focus-visible, .page-head :focus-visible, .btn:not(.btn-ghost):not(.btn-link):focus-visible, .fab:focus-visible { outline-color: var(--gold); }

.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; top: -100px; right: var(--sp-3); z-index: 100; background: var(--primary); color: var(--on-primary); padding: var(--sp-2) var(--sp-4); border-radius: var(--r-sm); }
.skip-link:focus { top: var(--sp-3); }

/* ── app shell ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) var(--sp-4) 0;
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--primary); color: var(--on-primary);
}
.topbar-logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: rgba(255,255,255,0.12); box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }
.topbar-title { font-family: var(--font-head); font-size: var(--fs-md); font-weight: 600; margin: 0; color: inherit; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn-icon { color: inherit; }

.main {
  width: 100%; max-width: var(--content-w); margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) calc(var(--nav-h) + var(--safe-b) + var(--sp-6));
  min-height: 60dvh;
}
.main:focus { outline: none; }
/* page transition: content fades up while the band stays put */
.main.is-entering > *:not(.page-head) { animation: view-in 260ms var(--ease-out) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }
.section { margin-bottom: var(--sp-5); }
.stack > * + * { margin-top: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.center { text-align: center; }

/* ── splash (P0) — pre-painted in index.html, filled by JS ── */
.splash {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
  background: radial-gradient(120% 90% at 50% 0%, var(--primary) 0%, var(--primary-deep) 58%, var(--primary-abyss, #0A2B25) 100%);
  color: #F8F5EC;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
.splash[hidden] { display: none !important; }
.splash-inner { width: min(100%, 420px); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); }
.splash-logo { width: 128px; height: 128px; border-radius: 50%; object-fit: cover; background: rgba(255,255,255,0.08); box-shadow: 0 0 0 4px rgba(201,168,76,0.35); }
.splash-symbol { width: 200px; height: 178px; }
/* the platform mark leads and the project's mark sits under it; both shrink so the card still fits */
.splash-inner.has-project .splash-symbol { width: 132px; height: 118px; }
.splash-inner.has-project .splash-logo { width: 96px; height: 96px; }
.splash-inner.has-project .splash-brand { font-size: 1.7rem; height: 2.4rem; line-height: 2.4rem; }
.splash-brand { font-family: var(--font-head); font-size: var(--fs-2xl); font-weight: 600; color: var(--gold-light); margin: 0; letter-spacing: 0.02em; height: 3rem; line-height: 3rem; }
.splash-project { font-family: var(--font-head); font-size: var(--fs-lg); margin: 0; color: #F8F5EC; height: 2rem; line-height: 2rem; }
.splash-project[hidden] { display: block !important; visibility: hidden; }
.splash-text { font-family: var(--font-splash); font-size: 1.2rem; line-height: 1.9; margin: 0; color: #F8F5EC; min-height: 3.8em; max-width: 340px; white-space: pre-line; }
/* the dedication splash is owner-locked: pin its button to the tenant accent so decoupling the platform gold
   from the accent does not change how it looks today */
.splash-btn { min-width: 160px; background: var(--accent); color: var(--on-accent); }
.splash-btn:hover { background: var(--accent); filter: brightness(0.94); }
.splash-bismillah { font-family: var(--font-splash); font-size: 1.35rem; margin: 0; color: var(--gold-light); height: 2rem; line-height: 2rem; }
.splash-sep { width: 120px; height: 1px; background: rgba(235, 208, 138, 0.5); }
.splash-foot { font-family: var(--font-splash); font-size: 1.0625rem; margin: 0; color: rgba(248, 245, 236, 0.85); height: 1.6rem; line-height: 1.6rem; }

/* ── skeleton / loading ── */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); min-height: 1em; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
  transform: translateX(100%); animation: shimmer 1.3s infinite;
}
.skeleton-line { height: 1em; margin-bottom: var(--sp-2); }
.skeleton-card { height: 84px; margin-bottom: var(--sp-3); border-radius: var(--r-md); }
@keyframes shimmer { to { transform: translateX(-100%); } }

.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: var(--sp-5) auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  :root { --dur-fast: 0.01ms; --dur: 0.01ms; --dur-slow: 0.01ms; }
  .main.is-entering > *, .tiles > .tile, .sheet, .sheet::backdrop, .toast, .cell.is-changed, .nav-item[aria-current="page"] .icon,
  .ring-wrap.is-done .ring-fill, .list-item.is-leaving, .fab { animation: none !important; }
  .ring-fill, .progress-bar, .nav-item .icon, .switch-track::after { transition: none !important; }
  .skeleton::after { animation: none; }
  html { scroll-behavior: auto; }
}

/* wide screens: side navigation */
@media (min-width: 900px) {
  body { padding-inline-start: 240px; }
  .main { padding-bottom: var(--sp-6); }
}
