/* 99House – light "blueprint" theme */

:root {
  --paper: #f4f6f8;
  --surface: #ffffff;
  --ink: #0e1b2a;
  --ink-2: #33455a;
  --muted: #566679;
  --line: #d9e0e8;
  --grid: rgba(42, 79, 214, .07);
  --blue: #2a4fd6;
  --blue-deep: #1b3aa8;
  --marigold: #f5a300;
  --marigold-soft: #fff3d6;

  --f-ui: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-read: "Source Serif 4", Georgia, "Times New Roman", serif;

  --r: 14px;
  --gutter: 20px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 var(--f-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--f-ui); line-height: 1.15; margin: 0; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
button, input { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 4px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

.wrap { width: min(1160px, 100% - 2 * var(--gutter)); margin-inline: auto; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(244, 246, 248, .88);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header__row { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand__mark { width: 30px; height: 30px; }
.brand__name { font-weight: 800; font-size: 1.3rem; letter-spacing: -.02em; }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: .95rem; }
.nav a:hover { background: #e7ecf2; color: var(--ink); }
.nav__search { margin-left: 8px; }
.nav__search input {
  width: 170px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: .92rem;
}
.nav__search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42, 79, 214, .15); }

.nav-toggle { display: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; position: relative; }
.nav-toggle span { position: absolute; left: 12px; right: 12px; height: 2px; background: var(--ink); transition: transform .2s, top .2s; }
.nav-toggle span:first-child { top: 17px; }
.nav-toggle span:last-child { top: 25px; }
.nav-toggle[aria-expanded="true"] span:first-child { top: 21px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { top: 21px; transform: rotate(-45deg); }

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; align-items: stretch; gap: 0; padding: 10px var(--gutter) 18px;
    background: var(--paper); border-bottom: 1px solid var(--line);
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px 6px; border-radius: 0; border-bottom: 1px solid var(--line); }
  .nav__search { margin: 12px 0 0; }
  .nav__search input { width: 100%; }
}

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: .98rem; text-decoration: none; cursor: pointer; line-height: 1.2;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: var(--blue-deep); }
.btn--ghost { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: #fff; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); font-size: .92rem; font-weight: 500; color: var(--ink-2);
  transition: border-color .15s, color .15s;
}
.chip span { color: var(--muted); font-size: .82rem; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.is-on span { color: #c5d0de; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); background: var(--paper); }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-mask-image: radial-gradient(ellipse 70% 90% at 72% 50%, #000 30%, transparent 78%);
  mask-image: radial-gradient(ellipse 70% 90% at 72% 50%, #000 30%, transparent 78%);
}
.hero__grid { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: center; padding-block: 40px 28px; }
.hero__copy { min-width: 0; }
.hero__title {
  font-size: clamp(2.4rem, 6.4vw, 4.5rem); font-weight: 800; letter-spacing: -.035em; line-height: 1.02;
  max-width: 13ch; text-wrap: balance;
}
.hero__lead { margin-top: 20px; max-width: 46ch; font-size: 1.15rem; line-height: 1.55; color: var(--ink-2); }
.hero__actions { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.hero__search { display: flex; gap: 8px; }
.hero__search input {
  width: 200px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.hero__search input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42, 79, 214, .15); }

.hero__stage { position: relative; aspect-ratio: 5 / 4; width: 100%; max-width: 620px; justify-self: center; }
.hero__stage canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; opacity: 0; transition: opacity .9s ease; }
.hero__fallback { position: absolute; inset: 6% 4%; width: 92%; height: 88%; transition: opacity .6s ease; }
.hero__stage.is-live canvas { opacity: 1; }
.hero__stage.is-live .hero__fallback { opacity: 0; }

@media (min-width: 900px) {
  .hero__grid { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; padding-block: 56px 48px; min-height: 560px; }
}

.strip { padding-block: 22px 4px; }

/* ---------- Sections ---------- */
.section { padding-block: 40px 56px; }
.section--tight { padding-top: 8px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section__title { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -.02em; }
.section__link { font-weight: 600; color: var(--blue-deep); text-underline-offset: 4px; }
.empty { padding: 36px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); text-align: center; background: var(--surface); }

.page-head { padding-block: 40px 20px; }
.page-head--center { text-align: center; padding-block: 90px 100px; }
.page-head__title { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -.03em; }
.page-head__lead { margin-top: 10px; color: var(--ink-2); font-size: 1.08rem; max-width: 60ch; }
.page-head--center .page-head__lead { margin-inline: auto; margin-bottom: 26px; }
.page-head .chips { margin-top: 20px; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { text-decoration: none; color: var(--blue-deep); }
.crumbs a:hover { text-decoration: underline; }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 22px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
  transition: border-color .15s;
}
.card:hover { border-color: var(--ink); }
.card__media { display: block; aspect-ratio: 16 / 10; background: #e9eef4; overflow: hidden; }
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__art {
  display: grid; place-items: center; width: 100%; height: 100%;
  background-color: hsl(var(--hue) 55% 94%);
  background-image:
    linear-gradient(hsl(var(--hue) 45% 70% / .22) 1px, transparent 1px),
    linear-gradient(90deg, hsl(var(--hue) 45% 70% / .22) 1px, transparent 1px);
  background-size: 24px 24px;
  color: hsl(var(--hue) 45% 28%);
}
.card__art svg { width: 38%; }
.card__body { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px 20px; flex: 1; }
.card__cat { align-self: flex-start; font-size: .84rem; font-weight: 600; color: var(--blue-deep); text-decoration: none; }
.card__cat:hover { text-decoration: underline; }
.card__title { font-size: 1.28rem; font-weight: 700; letter-spacing: -.015em; line-height: 1.22; }
.card__title a { text-decoration: none; }
.card__title a:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; text-decoration-color: var(--marigold); }
.card__text { color: var(--ink-2); font-size: .98rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card__meta { margin-top: auto; padding-top: 6px; color: var(--muted); font-size: .86rem; }

@media (min-width: 640px) {
  .card--lead { grid-column: 1 / -1; }
}
@media (min-width: 980px) {
  .card--lead { grid-column: span 2; flex-direction: row; }
  .card--lead .card__media { flex: 0 0 52%; aspect-ratio: auto; min-height: 100%; }
  .card--lead .card__body { padding: 28px; justify-content: center; }
  .card--lead .card__title { font-size: 1.85rem; }
  .card--lead .card__text { -webkit-line-clamp: 4; font-size: 1.04rem; }
  .card--lead .card__meta { margin-top: 12px; }
}

.pager { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 36px; }
.pager__btn { padding: 10px 18px; border: 1px solid var(--ink); border-radius: 10px; text-decoration: none; font-weight: 600; }
.pager__btn:hover { background: var(--ink); color: #fff; }
.pager__info { color: var(--muted); font-size: .92rem; }

.search-big { display: flex; gap: 10px; margin-top: 16px; max-width: 560px; }
.search-big input { flex: 1; min-width: 0; padding: 13px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.search-big input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42, 79, 214, .15); }

/* ---------- Article ---------- */
.article.wrap { width: min(1000px, 100% - 2 * var(--gutter)); padding-block: 36px 24px; }
.article__head { max-width: 760px; margin-bottom: 26px; }
.article__title { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.08; text-wrap: balance; }
.article__lead { margin-top: 16px; font-family: var(--f-read); font-size: 1.28rem; line-height: 1.5; color: var(--ink-2); }
.article__meta { margin-top: 18px; color: var(--muted); font-size: .92rem; }
.article__figure { margin: 0 0 30px; }
.article__figure img { width: 100%; height: auto; border-radius: var(--r); border: 1px solid var(--line); }
.article--page .article__head { margin-bottom: 8px; }

.article__layout { display: grid; gap: 28px; }
@media (min-width: 1000px) {
  .article__layout { grid-template-columns: 230px minmax(0, 1fr); gap: 56px; align-items: start; }
  .toc { position: sticky; top: 88px; }
}
.toc { font-size: .93rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 14px 16px; }
.toc summary { cursor: pointer; font-weight: 700; padding: 2px 0; }
.toc ol { list-style: none; margin-top: 10px; display: grid; gap: 2px; }
.toc a { display: block; padding: 5px 0; text-decoration: none; color: var(--ink-2); line-height: 1.3; }
.toc a:hover { color: var(--blue-deep); text-decoration: underline; }
.toc__l3 { padding-left: 14px; }
@media (min-width: 1000px) { .toc { border: 0; background: none; padding: 0; } .toc summary { pointer-events: none; list-style: none; } .toc summary::-webkit-details-marker { display: none; } }

.prose { font-family: var(--f-read); font-size: 1.14rem; line-height: 1.78; color: #1b2a3b; min-width: 0; max-width: 700px; }
.prose--solo { max-width: 700px; }
.prose > * + * { margin-top: 1.15em; }
.prose h2 { font-family: var(--f-ui); font-size: 1.85rem; font-weight: 800; letter-spacing: -.025em; margin-top: 2.1em; color: var(--ink); scroll-margin-top: 90px; }
.prose h3 { font-family: var(--f-ui); font-size: 1.3rem; font-weight: 700; letter-spacing: -.015em; margin-top: 1.7em; color: var(--ink); scroll-margin-top: 90px; }
.prose h2 + *, .prose h3 + * { margin-top: .6em; }
.prose a { color: var(--blue-deep); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li + li { margin-top: .4em; }
.prose li::marker { color: var(--marigold); font-weight: 700; }
.prose blockquote { margin-inline: 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--marigold); color: var(--ink-2); }
.prose img { height: auto; border-radius: 10px; border: 1px solid var(--line); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2em; }
.prose code { font-size: .88em; background: #e8edf3; padding: .12em .4em; border-radius: 5px; }
.prose pre { overflow-x: auto; background: var(--ink); color: #e6edf5; padding: 16px 18px; border-radius: 10px; font-size: .92rem; line-height: 1.6; }
.prose pre code { background: none; padding: 0; color: inherit; }
.prose strong { color: var(--ink); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.prose table { border-collapse: collapse; width: 100%; font-family: var(--f-ui); font-size: .96rem; line-height: 1.45; }
.prose th, .prose td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.prose th { background: #eef2f7; font-weight: 700; white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0 !important; margin-top: 2em !important; font-family: var(--f-ui); }
.tags a { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .86rem; text-decoration: none; color: var(--ink-2); background: var(--surface); }
.tags a:hover { border-color: var(--ink); }

.note { font-family: var(--f-ui); font-size: .92rem; line-height: 1.55; color: #5a4300; background: var(--marigold-soft); border: 1px solid #f0d58f; border-radius: 10px; padding: 12px 16px; margin-top: 2em !important; }
.author { display: flex; gap: 16px; align-items: center; font-family: var(--f-ui); border-top: 1px solid var(--line); padding-top: 22px; margin-top: 2em !important; }
.author__mark { flex: none; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 800; font-size: 1.3rem; }
.author__name { font-weight: 700; }
.author__bio { font-size: .94rem; color: var(--ink-2); line-height: 1.45; }

.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: var(--marigold); transform: scaleX(0); transform-origin: left; }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #c9d4e1; margin-top: 24px; }
.site-footer__grid { display: grid; gap: 32px; padding-block: 48px 28px; }
@media (min-width: 760px) { .site-footer__grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.brand--foot { color: #fff; }
.site-footer__about { margin-top: 14px; max-width: 34ch; color: #9fb0c4; font-size: .95rem; }
.site-footer__h { font-size: .98rem; font-weight: 700; color: #fff; margin-bottom: 12px; }
.site-footer ul { list-style: none; display: grid; gap: 8px; }
.site-footer a { color: #c9d4e1; text-decoration: none; font-size: .95rem; }
.site-footer a:hover { color: #fff; text-decoration: underline; text-underline-offset: 4px; }
.site-footer__base { border-top: 1px solid rgba(255, 255, 255, .12); padding-block: 18px 28px; font-size: .86rem; color: #8fa1b6; }

/* ---------- Small phones ---------- */
@media (max-width: 640px) {
  .hero__grid { padding-block: 22px 6px; gap: 6px; }
  .hero__title { font-size: clamp(1.9rem, 9.2vw, 2.5rem); max-width: none; }
  .hero__lead { font-size: 1.02rem; margin-top: 12px; }
  .hero__actions { margin-top: 18px; flex-direction: column; align-items: stretch; gap: 10px; }
  .hero__search { width: 100%; }
  .hero__search input { flex: 1; min-width: 0; width: auto; }
  .hero__stage { max-width: 210px; aspect-ratio: 5 / 3.3; }
  .strip { padding-block: 14px 0; }
  .strip .chips, .page-head .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .strip .chips::-webkit-scrollbar, .page-head .chips::-webkit-scrollbar { display: none; }
  .chips li { flex: none; }
  .section { padding-block: 22px 36px; }
  .section__title { font-size: 1.45rem; }
  .article.wrap { padding-block: 22px 12px; }
  .prose { font-size: 1.06rem; line-height: 1.72; }
  .prose h2 { font-size: 1.5rem; }
  .card__body { padding: 16px; }
  .page-head { padding-block: 24px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}