/* produx public website. Same token layers as app.css (raw palette →
 * semantic tokens → components); components only use semantic tokens.
 * No script on the site: the menu and dropdowns are CSS only. */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ── 1. Raw palette ─────────────────────────────────────────────────────────── */
:root {
  --white: #ffffff;
  --slate-50: #f8fafc;  --slate-100: #f1f5f9; --slate-200: #e2e8f0; --slate-300: #cbd5e1;
  --slate-400: #94a3b8; --slate-500: #64748b; --slate-600: #475569; --slate-700: #334155;
  --slate-800: #1e293b; --slate-900: #0f172a;
  --blue-50: #eff6ff;   --blue-100: #dbeafe;  --blue-500: #3b82f6;  --blue-600: #2563eb; --blue-700: #1d4ed8;
  --green-50: #f0fdf4;  --green-600: #16a34a; --green-700: #15803d;
  --red-50: #fef2f2;    --red-600: #dc2626;   --red-700: #b91c1c;
}

/* ── 2. Semantic tokens ─────────────────────────────────────────────────────── */
:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem; --text-lg: 1.125rem;
  --text-xl: 1.25rem; --text-2xl: 1.5rem; --text-3xl: 2rem;
  --leading-tight: 1.25; --leading-normal: 1.6;

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem;
  --space-5: 1.25rem; --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;

  --radius-sm: 0.375rem; --radius-md: 0.5rem; --radius-lg: 0.75rem; --radius-full: 9999px;
  --control-h: 2.75rem;

  --color-bg: var(--white);
  --color-surface: var(--white);
  --color-surface-2: var(--slate-50);
  --color-surface-hover: var(--slate-100);
  --color-border: var(--slate-200);
  --color-border-strong: var(--slate-300);
  --color-text: var(--slate-900);
  --color-text-body: var(--slate-700);
  --color-text-muted: var(--slate-500);
  --color-text-inverse: var(--white);
  --color-primary: var(--blue-600);
  --color-primary-hover: var(--blue-700);
  --color-primary-light: var(--blue-50);
  --color-success: var(--green-700); --color-success-bg: var(--green-50);
  --color-danger: var(--red-600);    --color-danger-bg: var(--red-50);

  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow-lg: 0 10px 30px rgb(15 23 42 / 0.16);
  --focus-ring: 0 0 0 3px rgb(59 130 246 / 0.35);

  --site-width: 72rem;
  --prose-width: 44rem;
  --gutter: var(--space-6);
}

/* ── 3. Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.site {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
input, textarea, button { font: inherit; color: inherit; }

.site-skip {
  position: absolute; left: var(--space-4); top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface); border-radius: var(--radius-md);
  z-index: 20; transform: translateY(-300%);
}
.site-skip:focus { transform: none; box-shadow: var(--shadow-lg); }

/* ── 4. Header and navigation ───────────────────────────────────────────────── */
.site-header { border-bottom: 1px solid var(--color-border); background: var(--color-surface); }
.site-bar {
  max-width: var(--site-width); margin: 0 auto; padding: 0 var(--gutter);
  min-height: 4rem; display: flex; align-items: center; gap: var(--space-6);
  position: relative;
}
.site-brand {
  font-weight: 700; font-size: var(--text-lg); color: var(--color-text);
  text-decoration: none; white-space: nowrap; margin-right: auto;
}
.site-nav-list, .site-sub, .site-tags { list-style: none; margin: 0; padding: 0; }
.site-nav-list { display: flex; align-items: center; gap: var(--space-1); }
.site-nav-item { position: relative; }
.site-nav-item > a, .site-sub a {
  display: block; padding: var(--space-2) var(--space-3);
  color: var(--color-text-body); text-decoration: none; font-size: var(--text-sm); font-weight: 500;
  border-radius: var(--radius-md); white-space: nowrap;
}
.site-nav-item > a:hover, .site-sub a:hover { background: var(--color-surface-hover); color: var(--color-text); }
.site-nav-item > a[aria-current="page"], .site-sub a[aria-current="page"],
.site-nav-item.in-trail > a { color: var(--color-primary); }
.has-sub > a::after { content: " ▾"; font-size: var(--text-xs); color: var(--color-text-muted); }

/* Dropdowns: shown while hovered or while focus is inside, so keyboard
 * users Tab into them and out again; no script. */
.site-sub {
  display: none; position: absolute; top: 100%; left: 0; z-index: 10;
  min-width: 13rem; padding: var(--space-2);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.has-sub:hover > .site-sub, .has-sub:focus-within > .site-sub { display: block; }

.site-menu-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.site-menu-button { display: none; }

/* ── 5. Layout ──────────────────────────────────────────────────────────────── */
.site-main { flex: 1; width: 100%; }
.site-container { max-width: var(--site-width); margin: 0 auto; padding: var(--space-10) var(--gutter) var(--space-12); }
.site-article { max-width: var(--prose-width); margin: 0 auto; padding: var(--space-10) var(--gutter) var(--space-12); }
.site-title { font-size: var(--text-3xl); line-height: var(--leading-tight); margin: 0 0 var(--space-4); overflow-wrap: anywhere; }
.site-page-head { margin-bottom: var(--space-6); }
.site-crumb { margin: 0 0 var(--space-2); font-size: var(--text-sm); }
.site-crumb a { color: var(--color-text-muted); }
.site-date { color: var(--color-text-muted); font-size: var(--text-sm); margin: 0 0 var(--space-3); display: block; }
.site-lede { font-size: var(--text-lg); color: var(--color-text-body); margin: 0 0 var(--space-4); }
.site-section { margin-top: var(--space-10); }
.site-section-title { font-size: var(--text-xl); margin: 0 0 var(--space-4); }
.site-more { margin: var(--space-6) 0 0; font-weight: 500; }
.site-empty { color: var(--color-text-muted); }
.site-cover {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: var(--radius-lg); margin: 0 0 var(--space-8); background: var(--color-surface-2);
}

/* Stored content */
.site-prose { color: var(--color-text-body); overflow-wrap: anywhere; }
.site-prose h1 { font-size: var(--text-3xl); line-height: var(--leading-tight); color: var(--color-text); margin: 0 0 var(--space-4); }
.site-prose h2 { font-size: var(--text-2xl); line-height: var(--leading-tight); color: var(--color-text); margin: var(--space-8) 0 var(--space-3); }
.site-prose h3 { font-size: var(--text-xl); color: var(--color-text); margin: var(--space-6) 0 var(--space-2); }
.site-prose p, .site-prose ul, .site-prose ol, .site-prose blockquote, .site-prose table { margin: 0 0 var(--space-4); }
.site-prose img { border-radius: var(--radius-md); margin: var(--space-4) 0; }
.site-prose blockquote { border-left: 3px solid var(--color-border-strong); padding-left: var(--space-4); color: var(--color-text-muted); }
.site-prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.site-prose td, .site-prose th { border: 1px solid var(--color-border); padding: var(--space-1) var(--space-2); }
.site-prose pre { max-width: 100%; overflow-x: auto; background: var(--color-surface-2); padding: var(--space-3); border-radius: var(--radius-md); }
.site-intro { max-width: var(--prose-width); }

/* A page made with the page builder: its export keeps its own layout and
   styles (scoped to .site-builder on save). Unlayer's body fills the
   viewport in its own preview; on the site it is as tall as its content. */
.site-builder #u_body, .site-builder .u_body { min-height: 0 !important; }
/* The page title of a builder page without its own h1: for screen readers
   and the document outline only. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.site-builder img { max-width: 100%; height: auto; }
article.site-builder { width: 100%; overflow-x: clip; }

/* ── 6. Posts ───────────────────────────────────────────────────────────────── */
.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-6); }
.post-card {
  display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--color-surface);
}
.post-card-cover { display: block; aspect-ratio: 16 / 9; background: var(--color-surface-2); }
.post-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.post-card-body { padding: var(--space-4) var(--space-5) var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.post-card-body .site-date { margin: 0; }
.post-card-title { font-size: var(--text-lg); line-height: var(--leading-tight); margin: 0; overflow-wrap: anywhere; }
.post-card-title a { color: var(--color-text); text-decoration: none; }
.post-card-title a:hover { color: var(--color-primary); text-decoration: underline; }
.post-card-excerpt {
  margin: 0; color: var(--color-text-body); font-size: var(--text-sm);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.post-featured .post-card { flex-direction: row; }
.post-featured .post-card-cover { flex: 0 0 55%; }
.post-featured .post-card-body { justify-content: center; padding: var(--space-6); }
.post-featured .post-card-title { font-size: var(--text-2xl); }

.site-tags { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.site-tag {
  display: inline-block; padding: 0.125rem var(--space-3); border-radius: var(--radius-full);
  background: var(--color-primary-light); color: var(--color-primary);
  font-size: var(--text-xs); font-weight: 500; text-decoration: none;
}
.site-tag:hover, .site-tag[aria-current="page"] { background: var(--color-primary); color: var(--color-text-inverse); }
.site-tag-nav { margin-bottom: var(--space-2); }
.site-article-head .site-tags { margin-bottom: var(--space-6); }

.site-pager {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-4);
  margin-top: var(--space-8); font-size: var(--text-sm);
}
.site-pager-at { color: var(--color-text-muted); }
.site-pager-next { justify-self: end; }

/* ── 7. Contact form ────────────────────────────────────────────────────────── */
.contact-form { display: flex; flex-direction: column; gap: var(--space-5); margin-top: var(--space-6); }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field label { font-weight: 500; font-size: var(--text-sm); }
.field-optional { color: var(--color-text-muted); font-weight: 400; }
.field input, .field textarea {
  width: 100%; min-height: var(--control-h); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface);
}
.field textarea { resize: vertical; }
.field input:focus-visible, .field textarea:focus-visible { border-color: var(--color-primary); }
.field.has-error input, .field.has-error textarea { border-color: var(--color-danger); }
.field-error { margin: 0; color: var(--color-danger); font-size: var(--text-sm); }
.contact-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.site-button {
  align-self: flex-start; min-height: var(--control-h); padding: 0 var(--space-6);
  border: 0; border-radius: var(--radius-md); cursor: pointer;
  background: var(--color-primary); color: var(--color-text-inverse); font-weight: 600;
}
.site-button:hover { background: var(--color-primary-hover); }
.site-notice { padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg); margin: var(--space-6) 0 0; }
.site-notice h2 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.site-notice p { margin: 0 0 var(--space-2); }
.site-notice p:last-child { margin-bottom: 0; }
.site-notice-success { background: var(--color-success-bg); color: var(--color-success); }
.site-notice-error { background: var(--color-danger-bg); color: var(--color-danger); margin: 0; }

/* ── 8. 404 and errors ──────────────────────────────────────────────────────── */
.site-404 { text-align: center; }
.site-404-code { font-size: var(--text-3xl); font-weight: 700; color: var(--color-text-muted); margin: 0 0 var(--space-2); }
.site-404-links { display: flex; justify-content: center; gap: var(--space-6); }

/* ── 9. Footer ──────────────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--color-border); background: var(--color-surface-2); color: var(--color-text-muted); font-size: var(--text-sm); }
.site-footer-inner {
  max-width: var(--site-width); margin: 0 auto; padding: var(--space-6) var(--gutter);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3) var(--space-6);
}
.site-footer nav { display: flex; gap: var(--space-5); }
.site-footer a { color: var(--color-text-muted); }

/* ── 10. Narrow screens ─────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  :root { --gutter: var(--space-4); }
  .site-title, .site-prose h1 { font-size: var(--text-2xl); }
  .post-grid { grid-template-columns: minmax(0, 1fr); }
  .post-featured .post-card { flex-direction: column; }
  .post-featured .post-card-body { padding: var(--space-4) var(--space-5) var(--space-5); }
  .post-featured .post-card-title { font-size: var(--text-xl); }
  .site-container, .site-article { padding-top: var(--space-6); }

  /* The menu folds behind a button; sub-items show as an indented list. */
  .site-bar { flex-wrap: wrap; }
  .site-menu-button {
    display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0 var(--space-4);
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
    font-size: var(--text-sm); font-weight: 500; cursor: pointer; user-select: none;
  }
  .site-menu-toggle:focus-visible + .site-menu-button { box-shadow: var(--focus-ring); }
  .site-menu-toggle:checked + .site-menu-button { background: var(--color-surface-hover); }
  .site-nav { display: none; flex-basis: 100%; padding-bottom: var(--space-3); }
  .site-menu-toggle:checked ~ .site-nav { display: block; }
  .site-nav-list { flex-direction: column; align-items: stretch; }
  .site-nav-item > a, .site-sub a { white-space: normal; padding: var(--space-3); }
  .has-sub > a::after { content: none; }
  .site-sub, .has-sub:hover > .site-sub, .has-sub:focus-within > .site-sub {
    display: block; position: static; min-width: 0; padding: 0 0 0 var(--space-4);
    border: 0; box-shadow: none; background: none;
  }
  .site-pager { grid-template-columns: 1fr 1fr; }
  .site-pager-at { grid-column: 1 / -1; grid-row: 2; text-align: center; }
}
