/* ============================================================
   blog.yusufaw.me — site styles
   Brand accent tokens come from theme.css (loaded first).
   Light/dark surfaces are defined here via [data-theme].
   ============================================================ */

/* ---------- Design tokens: light (default) ---------- */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f8f8;
  --surface: #ffffff;
  --surface-2: #f1f5f5;
  --text: #1a1f22;
  --text-muted: #5b676c;
  --border: #e4e9ea;
  --code-bg: #f4f6f7;
  --shadow: 0 1px 2px rgba(16, 24, 28, .04), 0 4px 16px rgba(16, 24, 28, .06);

  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 760px;        /* comfortable reading width */
  --maxw-wide: 1080px;  /* layout width for grids */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- Design tokens: dark ---------- */
[data-theme="dark"] {
  --bg: #0f1416;
  --bg-soft: #141b1d;
  --surface: #161d20;
  --surface-2: #1c2528;
  --text: #e6edee;
  --text-muted: #9aa9ad;
  --border: #273236;
  --code-bg: #131a1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);

  /* Brighten accents slightly for contrast on dark surfaces */
  --accent: #58b3c0;
  --accent-hover: #7cc6d1;
  --accent-soft: #16282c;
  --accent-border: #244349;
}

/* ---------- Base / reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; color: var(--text); }
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.container { width: 100%; max-width: var(--maxw-wide); margin: 0 auto; padding: 0 1.25rem; }
main.container { flex: 1 0 auto; padding-top: 2.5rem; padding-bottom: 4rem; }

/* ---------- Accessibility helpers ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: .65rem 1.25rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .95rem; cursor: pointer; border: 1px solid transparent;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(var(--accent-rgb), 0); backdrop-filter: saturate(180%) blur(10px);
  background-color: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 1rem; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: .95rem;
}
.brand-text { letter-spacing: -.01em; }

.site-nav { margin-left: auto; }
.nav-menu { display: flex; align-items: center; gap: .35rem; list-style: none; margin: 0; padding: 0; }
.nav-menu a {
  display: inline-block; padding: .45rem .7rem; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: .95rem;
}
.nav-menu a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-menu a.active { color: var(--accent); background: var(--accent-soft); }

.header-actions { display: flex; align-items: center; gap: .25rem; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: transparent; border: none; color: var(--text-muted); cursor: pointer;
}
.icon-btn:hover { color: var(--accent); background: var(--surface-2); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle-bar { display: block; width: 22px; height: 2px; background: var(--text); margin: 4px 0; border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }

/* ---------- Hero ---------- */
.hero { padding: 3rem 0 2rem; max-width: var(--maxw); margin: 0 auto; }
.hero-eyebrow { color: var(--accent); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; font-size: .8rem; margin: 0 0 .5rem; }
.hero-name { font-size: clamp(2rem, 5vw, 2.8rem); margin: 0 0 1rem; letter-spacing: -.02em; }
.hero-desc { font-size: 1.15rem; color: var(--text-muted); margin: 0 0 1.75rem; max-width: 38rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ---------- Sections / grids ---------- */
.section { max-width: var(--maxw-wide); margin: 3rem auto 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.section-title { font-size: 1.4rem; margin: 0; }
.section-link { font-size: .9rem; font-weight: 600; white-space: nowrap; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }

.post-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.post-card:hover { border-color: var(--accent-border); transform: translateY(-2px); box-shadow: var(--shadow); }
.post-card-body { padding: 1.25rem; }
.post-card-title { font-size: 1.15rem; margin: 0 0 .5rem; }
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--accent); text-decoration: none; }
.post-card-summary { color: var(--text-muted); font-size: .95rem; margin: 0 0 .9rem; }
.post-card-meta { color: var(--text-muted); font-size: .82rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ---------- Tags ---------- */
.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; }
.tag {
  display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .65rem;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border);
  border-radius: 999px; font-size: .8rem; font-weight: 500;
}
.tag:hover { background: var(--accent); color: #fff; text-decoration: none; border-color: var(--accent); }
.tag-count { opacity: .7; font-size: .75rem; }
.tag-cloud { list-style: none; display: flex; flex-wrap: wrap; gap: .55rem; margin: 0; padding: 0; }
.tag-cloud.large .tag { padding: .4rem .9rem; font-size: .9rem; }

/* ---------- Page heads / lists ---------- */
.page-head { max-width: var(--maxw); margin: 0 auto 2rem; }
.page-title { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: 0 0 .5rem; letter-spacing: -.02em; }
.page-desc { color: var(--text-muted); margin: 0; }
.page-intro { color: var(--text-muted); margin-top: 1rem; }

.post-list { max-width: var(--maxw); margin: 0 auto; }
.post-row { padding: 1.5rem 0; border-bottom: 1px solid var(--border); }
.post-row:first-child { padding-top: 0; }
.post-row-title { font-size: 1.3rem; margin: 0 0 .4rem; }
.post-row-title a { color: var(--text); }
.post-row-title a:hover { color: var(--accent); text-decoration: none; }
.post-row-summary { color: var(--text-muted); margin: 0 0 .6rem; }
.empty { color: var(--text-muted); text-align: center; padding: 3rem 0; }

/* ---------- Pagination ---------- */
.pagination { max-width: var(--maxw); margin: 2.5rem auto 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-btn { padding: .5rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; color: var(--text); }
.page-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-btn.disabled { opacity: .4; pointer-events: none; }
.page-status { color: var(--text-muted); font-size: .85rem; }

/* ---------- Single post ---------- */
.post { max-width: var(--maxw); margin: 0 auto; }
.post-header { margin-bottom: 2rem; }
.post-kicker { margin: 0 0 .5rem; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.post-kicker a { color: var(--accent); }
.post-title { font-size: clamp(1.9rem, 5vw, 2.6rem); margin: 0 0 .75rem; letter-spacing: -.02em; }
.post-lead { font-size: 1.2rem; color: var(--text-muted); margin: 0 0 1rem; }
.post-meta { color: var(--text-muted); font-size: .9rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.post-meta a { color: var(--text-muted); }
.post-meta a:hover { color: var(--accent); }
.meta-sep { opacity: .5; }

/* Table of contents */
.toc {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin: 0 0 2.5rem;
}
.toc-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 0 0 .5rem; }
.toc ul { margin: 0; padding-left: 1.1rem; }
.toc li { margin: .2rem 0; }
.toc a { color: var(--text-muted); font-size: .92rem; }
.toc a:hover { color: var(--accent); }

/* Post content typography */
.post-content { font-size: 1.075rem; }
.post-content > * + * { margin-top: 1.25rem; }
.post-content h2 { font-size: 1.6rem; margin-top: 2.5rem; padding-top: .25rem; }
.post-content h3 { font-size: 1.3rem; margin-top: 2rem; }
.post-content h4 { font-size: 1.1rem; margin-top: 1.5rem; }
.post-content h2 a, .post-content h3 a, .post-content h4 a { color: inherit; }
.post-content ul, .post-content ol { padding-left: 1.4rem; }
.post-content li { margin: .35rem 0; }
.post-content a { text-decoration: underline; text-underline-offset: 2px; }
.post-content blockquote {
  margin: 1.5rem 0; padding: .5rem 1.25rem; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text);
}
.post-content blockquote p { margin: .5rem 0; }
.post-content img { border-radius: var(--radius); margin: 1.5rem auto; }
.post-content table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: .55rem .75rem; text-align: left; }
.post-content th { background: var(--surface-2); }

/* Inline + block code */
.post-content code {
  font-family: var(--font-mono); font-size: .9em;
  background: var(--code-bg); padding: .15em .4em; border-radius: 5px;
}
.post-content pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; overflow-x: auto; font-size: .9rem; line-height: 1.6;
}
.post-content pre code { background: none; padding: 0; font-size: inherit; }

/* Post footer / nav */
.post-tags { margin: 2.5rem 0 0; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2rem; }
.post-nav-link {
  display: flex; flex-direction: column; gap: .25rem; padding: 1rem;
  border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
}
.post-nav-link:hover { border-color: var(--accent); text-decoration: none; }
.post-nav-link.next { text-align: right; }
.post-nav-dir { font-size: .8rem; color: var(--text-muted); font-weight: 600; }
.post-nav-title { font-weight: 600; color: var(--text); }

/* ---------- Search ---------- */
.search { max-width: var(--maxw); margin: 0 auto; }
.search-field {
  display: flex; align-items: center; gap: .6rem; padding: .75rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.search-field:focus-within { border-color: var(--accent); }
.search-field svg { color: var(--text-muted); flex-shrink: 0; }
#search-input { flex: 1; border: none; background: none; color: var(--text); font-size: 1.05rem; outline: none; }
.search-status { color: var(--text-muted); font-size: .9rem; margin: 1rem 0; }

/* ---------- 404 ---------- */
.error-page { max-width: var(--maxw); margin: 3rem auto; text-align: center; }
.error-code { font-size: clamp(4rem, 14vw, 7rem); font-weight: 800; color: var(--accent); margin: 0; line-height: 1; letter-spacing: -.03em; }
.error-title { font-size: 1.8rem; margin: .5rem 0 .75rem; }
.error-desc { color: var(--text-muted); margin: 0 0 2rem; }
.error-page .hero-actions { justify-content: center; }

/* ---------- Footer ---------- */
.site-footer { flex-shrink: 0; border-top: 1px solid var(--border); background: var(--bg-soft); margin-top: 4rem; }
.footer-inner { padding: 2.5rem 1.25rem; display: grid; gap: 1.25rem; }
.footer-brand { display: flex; align-items: center; gap: .75rem; }
.footer-brand p { margin: 0; color: var(--text-muted); font-size: .92rem; max-width: 36rem; }
.footer-social { display: flex; gap: .5rem; }
.footer-social a { display: grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius-sm); color: var(--text-muted); }
.footer-social a:hover { color: var(--accent); background: var(--surface-2); }
.footer-copy { margin: 0; color: var(--text-muted); font-size: .85rem; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .nav-toggle { display: block; order: 3; }
  .site-nav { margin-left: auto; position: relative; }
  .nav-menu {
    position: absolute; right: 0; top: calc(100% + 12px); flex-direction: column; align-items: stretch;
    min-width: 180px; padding: .5rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); display: none;
  }
  .nav-menu.open { display: flex; }
  .nav-menu a { padding: .6rem .8rem; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-link.next { text-align: left; }
  .section-head { flex-wrap: wrap; }
}
