/* ===== Base / Tokens ===================================================== */
:root {
  /* layout */
  --container: 960px;
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius: 14px;

  /* colors (dark default) */
  --bg: #0b0d10;
  --panel: #12161b;
  --line: #1c232b;
  --fg: #e9edf1;
  --muted: #9aa6b2;
  --acc: #0a84ff; /* Apple-style blue */

  /* type */
  --fs-base: 16px;
  --lh: 1.6;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --panel: #f6f7f9;
    --line: #e6e9ee;
    --fg: #0b0d10;
    --muted: #5a6672;
    --acc: #0a84ff;
  }
}

/* ===== Resets / A11y ===================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--fs-base)/var(--lh) -apple-system, BlinkMacSystemFont, "SF Pro Text",
        "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", system-ui, sans-serif;
}

img, svg, video, canvas { display: block; height: auto; }

a { color: inherit; text-decoration: none; }
a:focus-visible,
button:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

.skip-link {
  position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden;
}
.skip-link:focus { position: static; width: auto; height: auto; padding: var(--space-2); background: var(--panel); }

/* ===== Layout ============================================================ */
.container { width: min(100% - 2rem, var(--container)); margin-inline: auto; }

.site-header {
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  border-bottom: 1px solid var(--line); /* keep the top-bar line everywhere */
}

.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) 0;
}

.brand {
  font-weight: 800; letter-spacing: .6px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.nav-links { display: flex; gap: var(--space-3); align-items: center; }
.nav-link {
  padding: .45rem .8rem;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: border-color .15s ease, background-color .15s ease, opacity .15s ease;
  opacity: .92;
}
.nav-link:hover { border-color: var(--line); opacity: 1; }
.nav-link.cta { border-color: var(--acc); }

/* Ghost button (for "All articles") */
.ghost-btn {
  padding: .45rem .8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  transition: border-color .15s ease, background-color .15s ease, opacity .15s ease;
  opacity: .92;
}
.ghost-btn:hover { border-color: var(--acc); opacity: 1; }

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: var(--space-8);
  color: var(--muted);
  padding: var(--space-6) 0;
  text-align: center;
}

/* ===== Hero ============================================================== */
.hero {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: var(--space-3);
  padding: clamp(2rem, 6vw, 4rem) 0 var(--space-6);
}

/* Avatar */
:root { --avatar-size: 120px; }
@media (min-width: 720px) { :root { --avatar-size: 128px; } }
.avatar {
  width: var(--avatar-size);
  height: var(--avatar-size);
  max-width: none;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
  flex: 0 0 auto;
}

.title { font-size: clamp(1.9rem, 4.5vw, 2.4rem); margin: 0; letter-spacing: -0.02em; }
.lead  { margin: 0; color: var(--muted); max-width: 80ch; }

/* ===== Sections ========================================================== */
.section {
  padding: var(--space-8) 0 var(--space-6);
  border-top: 1px solid var(--line);
  margin-top: var(--space-8);
}
.section h2 { margin: 0 0 var(--space-3); font-size: 1.15rem; letter-spacing: .5px; }

.muted { color: var(--muted); }

/* Cards & grids */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-3); }
.card  { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-4); }
.card h3 { margin: 0 0 .35rem; font-size: 1rem; }

.grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-3); }

.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.tags span { font-size: .8rem; padding: .2rem .55rem; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; }

/* Lists / links */
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.link { color: var(--acc); text-underline-offset: 2px; }

/* Typography alignment */
.section p, .card p, .grid p, .list { text-align: left; }

/* ===== Motion reduction ================================================== */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== Articles (minimal) =============================================== */
.a-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: var(--space-6, 1.5rem); }
.a-card { border: 1px solid var(--line, #e6e9ee); border-radius: var(--radius, 14px); background: var(--panel, #f6f7f9); transition: transform .12s ease, border-color .2s ease; }
.a-card:hover { transform: translateY(-2px); border-color: var(--acc, #0a84ff); }
.a-link { display:block; padding: var(--space-6, 1.5rem); color: inherit; text-decoration: none; }
.a-title { margin: 0 0 .25rem; font-size: 1.1rem; letter-spacing: -.01em; }
.a-meta  { color: var(--muted, #9aa6b2); font-size: .9rem; margin-bottom: .4rem; }
.a-excerpt { margin: 0; }

/* ===== All Articles list ================================================= */
/* Layout wrapper only — no visual border on the wrapper */
.a-list { display: grid; gap: var(--space-4, 1rem); }
.a-row  { border: 0; background: transparent; border-radius: var(--radius); }

/* The LINK is the visible “card” */
.a-row-link {
  display: block;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-6);
  transition: transform .12s ease, border-color .2s ease, background-color .2s ease;
}

/* Hover & keyboard focus: same feel as homepage cards */
.a-row:hover .a-row-link,
.a-row:focus-within .a-row-link,
.a-row-link:hover,
.a-row-link:focus-visible {
  border-color: var(--acc);
  transform: translateY(-2px);
  outline: none;
}

/* Accessible focus ring following the rounded shape */
.a-row-link:focus-visible { box-shadow: 0 0 0 2px var(--acc); }

.a-row-title { margin: 0; font-size: 1.05rem; }
.a-row-meta  { color: var(--muted, #9aa6b2); font-size: .9rem; margin: .2rem 0 .4rem; }
.a-row-excerpt { margin: 0; }

/* Reduce motion: keep border highlight, remove lift */
@media (prefers-reduced-motion: reduce) {
  .a-row-link { transition: border-color .2s ease; }
  .a-row:hover .a-row-link,
  .a-row:focus-within .a-row-link,
  .a-row-link:hover,
  .a-row-link:focus-visible { transform: none; }
}

/* ===== Reader content ==================================================== */
.a-head { margin-bottom: var(--space-6, 1.5rem); }
.a-h1  { margin: 0 0 .25rem; font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); letter-spacing: -.02em; }
.a-head-meta { color: var(--muted, #9aa6b2); }
.a-content   { max-width: 70ch; line-height: 1.75; font-size: 1.05rem; }
.a-content .lead { font-size: 1.12em; }
.a-content h2, .a-content h3 { margin-top: 2em; margin-bottom: .6em; letter-spacing: -.01em; }
.a-content p { margin: 0 0 1em; }

/* ===== Page titles above divider (All Articles & Reader) ================= */
.page-head { padding: var(--space-8) 0 var(--space-4); }
.page-title {
  margin: 0;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem);
  letter-spacing: -.02em;
}
.page-subtle-meta { color: var(--muted); margin-top: .25rem; }
.page-actions    { margin-top: var(--space-3); display: flex; gap: var(--space-3); align-items: center; }

/* ===== Page transitions (safe, JS opt-in) =============================== */
body { opacity: 1; }
body.js-fade { opacity: 0; transition: opacity .24s ease; }
body.js-fade.is-ready { opacity: 1; }
body.js-fade.is-leaving { opacity: 0; }
@media (prefers-reduced-motion: reduce) { body.js-fade { transition: none !important; } }

/* ===== Main page unified hover highlights (scoped to home only) ========= */
/* Scope: main page has no data-page attribute; subpages have data-page="…" */
body:not([data-page]) .card,
body:not([data-page]) .a-card { 
  transition: transform .12s ease, border-color .2s ease, background-color .2s ease; 
  will-change: transform;
}
body:not([data-page]) .card:hover,
body:not([data-page]) .card:focus-within,
body:not([data-page]) .a-card:hover,
body:not([data-page]) .a-card:focus-within {
  border-color: var(--acc);
  transform: translateY(-2px);
}

/* Header items highlight on hover/focus (home only) */
body:not([data-page]) .nav-link:hover,
body:not([data-page]) .nav-link:focus-visible,
body:not([data-page]) .ghost-btn:hover,
body:not([data-page]) .ghost-btn:focus-visible,
body:not([data-page]) .brand:hover,
body:not([data-page]) .brand:focus-visible {
  border-color: var(--acc);
  opacity: 1;
}

/* Inline text links on home: underline on hover/focus */
body:not([data-page]) .link:hover,
body:not([data-page]) .link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Avatar: subtle highlight on hover (home only) */
body:not([data-page]) .avatar {
  transition: border-color .2s ease, box-shadow .2s ease, transform .12s ease;
}
body:not([data-page]) .avatar:hover,
body:not([data-page]) .avatar:focus-visible {
  border-color: var(--acc);
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(0,0,0,.3);
}

/* Reduce motion on home */
@media (prefers-reduced-motion: reduce) {
  body:not([data-page]) .card,
  body:not([data-page]) .a-card,
  body:not([data-page]) .avatar { transition: border-color .2s ease, box-shadow .2s ease; }
  body:not([data-page]) .card:hover,
  body:not([data-page]) .card:focus-within,
  body:not([data-page]) .a-card:hover,
  body:not([data-page]) .a-card:focus-within,
  body:not([data-page]) .avatar:hover,
  body:not([data-page]) .avatar:focus-visible { transform: none; }
}

/* --- Social row under hero title --------------------------------------- */
.socials {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  margin-top: .25rem;
}

.s-btn {
  --size: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--size);
  height: var(--size);
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--fg);
  transition: transform .12s ease, border-color .2s ease, background-color .2s ease, opacity .2s ease;
  opacity: .95;
}

.s-btn:hover,
.s-btn:focus-visible {
  border-color: var(--acc);
  transform: translateY(-2px);
  opacity: 1;
  outline: none;
}

.s-btn:active { transform: translateY(-1px) scale(.98); }

.s-icon {
  width: 18px;
  height: 18px;
  display: block;
  fill: currentColor; /* Bootstrap Icons use fill="currentColor" */
}

/* Keyboard focus ring for accessibility */
.s-btn:focus-visible {
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--acc) 50%, transparent);
}

/* Equal vertical gap for the social row */
.socials { margin-top: 0; } /* clear the old .25rem */
.hero .title + .socials { margin-top: var(--space-3); }
.hero .socials + .lead { margin-top: var(--space-3); }
