/* ───────────────────────────────────────────────────────────
   Mark Faizi: design system
   Every colour is a token. Dark mode only redefines tokens.
   Never write a raw colour below the token blocks.
   ─────────────────────────────────────────────────────────── */

@font-face { font-family: Hanken; src: url('../assets/fonts/hanken.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: Playfair; src: url('../assets/fonts/playfair.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Playfair; src: url('../assets/fonts/playfair-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  color-scheme: light dark;

  /* Brand palette (7b) */
  --paper: #F5F3EC;
  --ink: #202B26;
  --lime: #D6ED79;
  --olive: #3F5317;

  /* Light theme tokens */
  --bg: var(--paper);
  --surface: #FFFFFF;
  --surface-hover: #FBFAF6;
  --surface-sunk: #ECE9DF;
  --text: var(--ink);
  --muted: #4F5A53;
  --line: rgb(32 43 38 / .11);
  --line-strong: rgb(32 43 38 / .22);
  --accent: var(--lime);          /* backgrounds only in light mode */
  --on-accent: var(--ink);
  --link: var(--olive);           /* small accents, focus rings */
  --tile: #F1F5E5;                /* sage tint behind icons */
  --tile-ink: var(--olive);
  --mark-bg: var(--lime);         /* marker-pen highlight behind one italic word */
  --mark-ink: var(--ink);
  --shadow: 0 1px 2px rgb(32 43 38 / .05), 0 6px 20px -8px rgb(32 43 38 / .10);

  /* Type */
  --font-sans: Hanken, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: Playfair, Georgia, 'Times New Roman', serif;
  --step--1: 13px;
  --step-0: 16px;
  --step-1: 18px;
  --step-2: 22px;
  --step-3: clamp(28px, 6vw, 38px);

  /* Shape and space */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --gutter: 20px;
  --measure: 600px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1412;
    --surface: #171E1A;
    --surface-hover: #1C2420;
    --surface-sunk: #131916;
    --text: #EDF0E8;
    --muted: #A6B0A8;
    --line: rgb(237 240 232 / .09);
    --line-strong: rgb(237 240 232 / .18);
    --link: var(--lime);          /* lime is readable as text on dark */
    --tile: #212A24;
    --tile-ink: var(--lime);
    --mark-bg: transparent;
    --mark-ink: var(--lime);
    --shadow: none;
  }
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 24px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 var(--step-0)/1.6 var(--font-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { display: block; max-width: 100%; }
.figure img { width: 100%; height: auto; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 400; text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: var(--lime); color: var(--ink); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); }
.skip:focus { top: 12px; }

.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i-chev { width: 18px; height: 18px; color: var(--muted); transition: transform .2s var(--ease); }

/* ── Layout ───────────────────────────────────────────────── */
.shell { width: min(var(--measure), 100% - 2 * var(--gutter)); margin-inline: auto; }
.page { padding-block: 28px 56px; }
@media (min-width: 720px) { .page { padding-block: 64px 80px; } }
.stack > * + * { margin-top: var(--space, 12px); }
.section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.section-head h2 { font: 600 var(--step-0)/1.3 var(--font-sans); letter-spacing: -.005em; }
.section-head span, .section-head a { color: var(--muted); font-size: var(--step--1); }
.section-head a:hover { color: var(--text); }

/* ── Profile (home + about) ───────────────────────────────── */
.profile { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.avatar { position: relative; display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; overflow: visible; background: var(--accent); color: var(--on-accent); flex: none; transition: transform .2s var(--ease); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-mono { font: 400 30px/1 var(--font-serif); letter-spacing: -.04em; }
.avatar-mono em { font-style: italic; }
.avatar-badge { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.avatar-badge .i { width: 14px; height: 14px; stroke-width: 2.2; }
a.avatar:hover { transform: scale(1.04); }
a.avatar:active { transform: scale(.97); }
.profile-name { font: 400 28px/1.1 var(--font-serif); letter-spacing: -.02em; }
.profile-name sup { font: 600 11px/1 var(--font-sans); letter-spacing: .04em; vertical-align: super; margin-left: 2px; color: var(--muted); }
.profile-bio { margin-top: 6px; color: var(--muted); font-size: 15.5px; line-height: 1.5; }
.profile-bio strong { color: var(--text); font-weight: 600; }
.profile-note { margin-top: 8px; font-size: var(--step--1); color: var(--muted); }

/* Social buttons: a light row of icon + label (Marc Lou style), each a full 44px tap target */
.socials { display: flex; flex-wrap: wrap; gap: 0 22px; margin-top: 14px; padding-left: 2px; }
.social { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; color: var(--muted); font-size: 14.5px; font-weight: 500; transition: color .2s; }
.social .i { width: 19px; height: 19px; color: var(--text); }
.social:hover { color: var(--text); }
.social:active { opacity: .7; }

/* ── Cards and link buttons ───────────────────────────────── */
.card { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: background-color .2s, border-color .2s, transform .15s var(--ease); }
a.card:hover { background: var(--surface-hover); border-color: var(--line-strong); }
a.card:hover .i-chev { transform: translateX(3px); color: var(--text); }
a.card:active { transform: scale(.985); }

.links { display: grid; gap: 10px; margin-top: 24px; }
.link-card { min-height: 64px; padding: 11px 14px 11px 11px; }
.link-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius-sm); background: var(--tile); color: var(--tile-ink); overflow: hidden; flex: none; }
.link-icon img { width: 100%; height: 100%; object-fit: cover; }
.link-text { display: grid; gap: 1px; min-width: 0; flex: 1; }
.link-title { font-weight: 600; font-size: var(--step-0); line-height: 1.3; }
.link-sub { color: var(--muted); font-size: 14px; line-height: 1.35; }
.link-meta { color: var(--muted); font-size: 12.5px; }
.link-card .i-chev { margin-left: auto; }

.link-card.is-featured { min-height: 76px; padding: 13px 16px 13px 13px; background: var(--accent); color: var(--on-accent); border-color: transparent; }
.link-card.is-featured:hover { background: var(--accent); filter: brightness(1.03); }
.link-card.is-featured .link-icon { width: 50px; height: 50px; border-radius: 12px; }
.link-card.is-featured .link-sub, .link-card.is-featured .i-chev { color: var(--on-accent); opacity: .78; }
.link-card.is-featured .link-title { font-size: 17px; }
.pill { display: inline-block; margin-bottom: 2px; padding: 2px 8px; border-radius: 999px; background: var(--on-accent); color: var(--accent); font: 600 11px/1.5 var(--font-sans); letter-spacing: .04em; text-transform: uppercase; justify-self: start; }

.ad-label { display: inline-block; margin: 0 0 6px 4px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.ad-label::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--lime); vertical-align: 1px; }

/* ── Project tiles ─────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 18px 12px; list-style: none; margin: 0; padding: 0; }
.tile { display: grid; justify-items: center; gap: 8px; text-align: center; }
.tile-art { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; overflow: hidden; background: var(--tile); color: var(--tile-ink); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .2s var(--ease); }
.tile-art img { width: 100%; height: 100%; object-fit: cover; }
.tile-art .i { width: 26px; height: 26px; stroke-width: 1.6; }
.tile-name { font-size: 12.5px; line-height: 1.25; color: var(--muted); max-width: 84px; }
.tile:hover .tile-art { transform: translateY(-2px); }
.tile:active .tile-art { transform: scale(.95); }
.tiles.is-large .tile-art { width: 72px; height: 72px; border-radius: 18px; }

/* ── Lazy section (home) ──────────────────────────────────── */
.lazy { min-height: 360px; }
.lazy.is-loaded, .lazy.is-failed { min-height: 0; }
.lazy-fallback { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-top: 40px; color: var(--muted); font-size: 14.5px; }
.lazy-fallback a { text-decoration: underline; text-underline-offset: 3px; }
.js .lazy:not(.is-failed) .lazy-fallback { visibility: hidden; }
.lazy.is-loaded > * { animation: rise .45s var(--ease) both; }
.lazy.is-loaded > *:nth-child(2) { animation-delay: .05s; }
.lazy.is-loaded > *:nth-child(3) { animation-delay: .1s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* Note rows and tool cards */
.rows { display: grid; gap: 10px; }
.row-card { display: grid; gap: 4px; padding: 16px 18px; }
.row-card .row-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; }
.row-card h3 { font: 400 20px/1.25 var(--font-serif); letter-spacing: -.01em; }
.row-card p { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.row-card .limit { font-size: 13.5px; }
.row-card.card { display: grid; align-items: start; }
.cta { display: grid; gap: 10px; padding: 22px; background: var(--surface-sunk); border-radius: var(--radius-lg); }
.cta h2 { font: 400 24px/1.2 var(--font-serif); }
.mark { font-style: italic; background: linear-gradient(transparent 62%, var(--mark-bg) 62% 92%, transparent 92%); color: var(--mark-ink); padding-inline: 2px; }
.cta p { color: var(--muted); }

/* Buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px; font-weight: 600; background: var(--text); color: var(--bg); transition: transform .15s var(--ease), opacity .2s; justify-self: start; }
.button:hover { opacity: .9; }
.button:active { transform: scale(.97); }
.button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); }
.text-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px; font-weight: 600; }
.text-link:hover { text-decoration-color: currentColor; }

/* ── Top bar (inner pages) ────────────────────────────────── */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.topbar nav { display: flex; gap: 2px; }
.topbar nav a { padding: 10px; border-radius: var(--radius-sm); font-size: 14.5px; color: var(--muted); }
.topbar nav a:hover, .topbar nav a[aria-current] { color: var(--text); }
.topbar nav a[aria-current] { font-weight: 600; }

/* ── Reading pages ────────────────────────────────────────── */
.page-title { font: 400 var(--step-3)/1.1 var(--font-serif); letter-spacing: -.025em; }
.page-title em { font-style: italic; }
.page-intro { margin-top: 12px; color: var(--muted); font-size: var(--step-1); line-height: 1.5; }
.prose { margin-top: 28px; font-size: 17px; line-height: 1.7; }
.prose > * + * { margin-top: 1em; }
.prose h2 { margin-top: 1.8em; font: 400 24px/1.25 var(--font-serif); }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose a:not(.button) { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.takeaway { padding: 16px 18px; border-left: 4px solid var(--lime); background: var(--surface-sunk); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.figure { margin: 28px 0 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 20px; color: var(--muted); font-size: 14.5px; }
.back .i { width: 16px; height: 16px; transform: rotate(180deg); }
.meta-line { color: var(--muted); font-size: var(--step--1); letter-spacing: .02em; }
.share { display: flex; gap: 18px; margin-top: 28px; font-size: 14.5px; }
.share button { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.resource-actions { display: flex; gap: 16px; padding: 6px 4px 0; font-size: 13px; color: var(--muted); }
.resource-actions a, .resource-actions button { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }

/* Filters */
.filter-bar { display: grid; gap: 12px; margin: 24px 0 16px; }
.search { width: 100%; min-height: 48px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.count { color: var(--muted); font-size: var(--step--1); margin-bottom: 10px; }
.empty { padding: 28px 22px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.empty h2, .empty h3 { color: var(--text); font: 400 22px/1.3 var(--font-serif); margin-bottom: 6px; }
.notice { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-sunk); color: var(--muted); font-size: 14px; }

/* Forms */
.form { display: grid; gap: 16px; margin-top: 20px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 14.5px; }
.form input, .form select, .form textarea, .output { width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 400; }
.form input, .form select { min-height: 48px; }
details summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

/* ── Footer ───────────────────────────────────────────────── */
.footer { margin-top: 56px; padding-block: 20px calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 18px; color: var(--muted); font-size: 13px; }
.footer nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.footer a:hover, .footer button:hover { color: var(--text); }
/* Wordmark: "MarkFaizi" in Playfair with a small raised "AI" (the original brand mark) */
.wordmark { display: inline-flex; align-items: baseline; min-height: 44px; padding-top: 6px; white-space: nowrap; color: var(--text); font: 400 26px/1 var(--font-serif); letter-spacing: -.035em; }
.wordmark-ai { position: relative; top: -.85em; margin-left: 3px; font: 400 .43em/1 var(--font-serif); letter-spacing: 0; vertical-align: baseline; }
.wordmark-sm { min-height: 0; padding-top: 0; font-size: 16px; letter-spacing: -.02em; }
@media (max-width: 350px) { .topbar .wordmark { font-size: 22px; } .topbar nav a { padding-inline: 7px; } }

/* ── Motion preferences ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
