/* ============================================================
   DABBA — base.css : reset, typography, chrome, layout grid
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--cream-100);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: var(--fs-body);            /* 18px body floor */
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, video { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4, p, figure, ul, ol, dl, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Decorative paper grain (imperceptible, aria-hidden) */
.grain {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Typography helpers */
.display { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-display); line-height: 1.1; }
.h1 { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h1); line-height: 1.2; }
.h2 { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h2); line-height: 1.27; }
.h3 { font-family: var(--font-body); font-weight: 600; font-size: var(--fs-h3); line-height: 1.3; }
.body { font-size: var(--fs-body); line-height: 1.55; }
.body-strong { font-weight: 600; }
.body-sm { font-size: var(--fs-body-sm); line-height: 1.5; color: var(--ink-700); }
.caption {
  font-size: var(--fs-caption); font-weight: 500; line-height: 1.28;
  letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink-500);
}
.num { font-size: var(--fs-num); font-variant-numeric: tabular-nums; font-weight: 600; }
.eyebrow { font-size: var(--fs-caption); font-weight: 500; line-height: 1.28; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink-500); margin-bottom: var(--space-2); }

/* ===== App shell ===== */
.app-shell { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

.page {
  flex: 1;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-8) var(--gutter-mobile) var(--space-20);
  outline: none;
}

/* ===== Top bar (sticky) ===== */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: var(--cream-100);
  border-bottom: 1px solid var(--cream-200);
}
.topbar-inner {
  max-width: var(--page-max); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--gutter-mobile);
  min-height: 60px;
}
.wordmark { display: flex; align-items: center; gap: var(--space-2); color: var(--mode-chrome); text-decoration: none; }
.wordmark:hover { text-decoration: none; }
.wordmark-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--mode-chrome); flex: none; }
.wordmark-text { font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; line-height: 1; }
.topnav { display: flex; gap: var(--space-1); }
.topnav a {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-input);
  color: var(--ink-700); font-weight: 500; font-size: var(--fs-body-sm);
}
.topnav a:hover { background: var(--cream-200); text-decoration: none; color: var(--ink-900); }
.topnav a.active { background: var(--accent-soft); color: var(--accent-strong); }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }

/* ===== Layout grid (feed) ===== */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}
.detail-grid {
  display: grid; gap: var(--space-8);
  grid-template-columns: 1fr;
}

/* ===== Section rhythm ===== */
.section { margin-bottom: var(--space-10); }
.section + .section { }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }

/* ===== Surfaces ===== */
.card {
  background: var(--white);
  border: 1px solid var(--cream-200);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}
.divider { border: none; border-top: 1px solid var(--cream-200); margin: 0; }

/* ===== Focus ===== */
:focus-visible { outline: none; box-shadow: var(--ring-focus); border-radius: var(--radius-input); }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Tablet ===== */
@media (min-width: 768px) {
  .feed-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }
  .detail-grid { grid-template-columns: minmax(0, 58%) minmax(320px, 42%); align-items: start; }
  .page { padding-left: var(--gutter-desktop); padding-right: var(--gutter-desktop); }
  .topbar-inner { padding-left: var(--gutter-desktop); padding-right: var(--gutter-desktop); }
}

/* ===== Desktop ===== */
@media (min-width: 1024px) {
  .feed-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Utility */
.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }
