/* =====================================================================
   Public site: header, footer, home additions, blog, CMS pages, contact.
   Loaded by layouts/public.php only. Built entirely on tokens.css, so the
   dark and high-contrast themes need no rules of their own here.
   ===================================================================== */

/* ---- header ---------------------------------------------------------- */
.site-header .site-brand { border: 0; height: auto; padding: 0; }
.site-header .app-brand__text { display: flex; }
.site-brand .app-brand__name { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.02em; }
.site-nav { justify-content: center; }

.site-menu { position: relative; display: none; }
.site-menu > summary { list-style: none; cursor: pointer; }
.site-menu > summary::-webkit-details-marker { display: none; }
.site-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  display: grid;
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  z-index: 60;
}
.site-menu__panel a { padding: 10px 12px; border-radius: var(--r-md); color: var(--text); font-weight: 550; }
.site-menu__panel a:hover, .site-menu__panel a[aria-current] { background: var(--surface-3); text-decoration: none; }
@media (max-width: 860px) {
  .site-menu { display: block; }
}

/* ---- footer ---------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: var(--sp-9) 0 var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.site-footer .site-brand { border: 0; height: auto; padding: 0; }
.site-footer__grid { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: var(--sp-8); }
.site-footer__title { font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text); margin: 0 0 var(--sp-3); }
.site-footer__links { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--sp-2); }
.site-footer__links a { color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.site-footer__links a:hover { color: var(--brand-text); }
.site-footer__about p { max-width: 42ch; }
.site-social { list-style: none; padding: 0; margin: var(--sp-4) 0 0; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.site-social a {
  display: inline-block; padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--r-full);
  color: var(--text-muted); font-weight: 550;
}
.site-social a:hover { border-color: var(--brand-500); color: var(--brand-text); text-decoration: none; }
.site-footer__bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-3);
  margin-top: var(--sp-8); padding-top: var(--sp-5); border-top: 1px solid var(--border); font-size: var(--fs-xs);
}
@media (max-width: 900px) {
  .site-footer__grid { grid-template-columns: 1fr 1fr; gap: var(--sp-6); }
  .site-footer__about { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .site-footer__grid { grid-template-columns: 1fr; }
}

/* ---- shared ---------------------------------------------------------- */
.h3 { font-size: var(--fs-lg); }
.h4 { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.mt-7 { margin-top: var(--sp-7); }
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---- home ------------------------------------------------------------ */
.mh-hero {
  background:
    radial-gradient(60rem 26rem at 50% -8rem, color-mix(in srgb, var(--brand-500) 16%, transparent), transparent 70%),
    linear-gradient(to bottom, transparent, var(--bg));
}
.mh-highlight {
  background: linear-gradient(120deg, var(--brand-600), #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
:root[data-theme="contrast"] .mh-highlight { background: none; color: inherit; }

/* ---- page heroes ----------------------------------------------------- */
.page-hero { padding: var(--sp-8) 0 var(--sp-6); border-bottom: 1px solid var(--border); background: var(--surface); }
.page-hero h1 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); letter-spacing: -0.025em; margin-bottom: var(--sp-2); }
.page-hero--brand {
  background:
    radial-gradient(50rem 20rem at 10% -6rem, color-mix(in srgb, var(--brand-500) 14%, transparent), transparent 70%),
    var(--surface);
}
.page-hero__lead { max-width: 64ch; font-size: var(--fs-lg); color: var(--text-muted); }
.page-hero__lead p { margin: 0 0 var(--sp-2); }

/* ---- long-form content (CMS pages and blog posts) --------------------- */
.prose { font-size: 1.0625rem; line-height: 1.75; color: var(--text); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2 { font-size: 1.5rem; letter-spacing: -0.015em; margin: 2.2em 0 0.6em; scroll-margin-top: 84px; }
.prose h3 { font-size: 1.2rem; margin: 1.8em 0 0.5em; scroll-margin-top: 84px; }
.prose h4 { font-size: 1.05rem; margin: 1.5em 0 0.4em; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table, .prose figure { margin: 0 0 1.15em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-bottom: 0.4em; }
.prose a { color: var(--brand-text); text-decoration: underline; text-underline-offset: 3px; }
.prose img { max-width: 100%; height: auto; border-radius: var(--r-lg); }
.prose figcaption { font-size: var(--fs-sm); color: var(--text-muted); text-align: center; margin-top: var(--sp-2); }
.prose blockquote {
  border-left: 4px solid var(--brand-500); background: var(--brand-50); color: var(--text);
  padding: var(--sp-4) var(--sp-5); border-radius: 0 var(--r-lg) var(--r-lg) 0; font-size: 1.1rem;
}
.prose blockquote p:last-child { margin-bottom: 0; }
:root[data-theme="dark"] .prose blockquote { background: var(--surface-3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .prose blockquote { background: var(--surface-3); } }
.prose code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-3); padding: 2px 5px; border-radius: var(--r-xs); }
.prose pre { background: var(--surface-3); padding: var(--sp-4); border-radius: var(--r-lg); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-3); }
.prose iframe { width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: var(--r-lg); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

/* ---- blog listing ---------------------------------------------------- */
.blog-hero { padding: var(--sp-8) 0 var(--sp-6); background: var(--surface); border-bottom: 1px solid var(--border); }
.blog-hero h1 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); letter-spacing: -0.025em; margin-bottom: var(--sp-2); }
.blog-hero__intro { color: var(--text-muted); max-width: 62ch; font-size: var(--fs-lg); }
.blog-search {
  display: flex; align-items: center; gap: var(--sp-2); max-width: 620px; margin-top: var(--sp-5);
  padding: 6px 6px 6px 14px; background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-full);
  color: var(--text-subtle);
}
.blog-search:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 22%, transparent); }
.blog-search .input { border: 0; box-shadow: none; background: transparent; padding-inline: 4px; min-width: 0; flex: 1; }
.blog-search .input:focus { outline: none; box-shadow: none; }
.blog-search .btn { border-radius: var(--r-full); }


.blog-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--sp-7); padding-block: var(--sp-7) var(--sp-9); }
.blog-aside { display: grid; gap: var(--sp-4); align-content: start; }
.blog-aside__list { list-style: none; margin: 0; padding: var(--sp-2) 0; }
.blog-aside__list li { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 8px var(--sp-5); font-size: var(--fs-sm); }
.blog-aside__list li + li { border-top: 1px solid var(--border); }
.blog-aside__list span { color: var(--text-subtle); }
.blog-cta { background: linear-gradient(150deg, var(--brand-50), var(--surface)); border-color: var(--brand-200); }
:root[data-theme="dark"] .blog-cta { background: var(--surface); border-color: var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .blog-cta { background: var(--surface); border-color: var(--border); } }
@media (max-width: 960px) {
  .blog-layout { grid-template-columns: 1fr; }
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tag {
  display: inline-block; padding: 4px 10px; border-radius: var(--r-sm); background: var(--surface-3);
  color: var(--text-muted); font-size: var(--fs-sm); font-weight: 550;
}
.tag:hover { color: var(--brand-text); text-decoration: none; }
.tag.is-active { background: var(--brand-600); color: #fff; }

.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-5); }
.post-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 960px) { .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .post-grid, .post-grid--2 { grid-template-columns: 1fr; } }

.post-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); overflow: hidden; transition: transform .15s ease, box-shadow .15s ease;
}
.post-card:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.post-card__media { display: block; aspect-ratio: 16 / 9; background: var(--surface-3); overflow: hidden; }
.post-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-card__placeholder {
  width: 100%; height: 100%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-50), color-mix(in srgb, var(--brand-200) 60%, var(--surface)));
}
:root[data-theme="dark"] .post-card__placeholder { background: linear-gradient(135deg, var(--surface-3), var(--surface)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .post-card__placeholder { background: linear-gradient(135deg, var(--surface-3), var(--surface)); } }
.post-card__body { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-5); flex: 1; }
.post-card__cat { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--brand-text); }
.post-card__title { font-size: var(--fs-lg); line-height: 1.35; margin: 0; letter-spacing: -0.01em; }
.post-card__title a { color: var(--text); }
.post-card__title a:hover { color: var(--brand-text); text-decoration: none; }
.post-card__excerpt { color: var(--text-muted); font-size: var(--fs-sm); margin: 0; }
.post-card__meta { color: var(--text-subtle); font-size: var(--fs-xs); margin: auto 0 0; padding-top: var(--sp-2); }

.post-featured {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; margin-bottom: var(--sp-6);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); overflow: hidden;
}
.post-featured__media { display: block; min-height: 240px; background: var(--surface-3); }
.post-featured__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-featured__body { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); justify-content: center; }
.post-featured__body h2 { font-size: var(--fs-xl); margin: 0; line-height: 1.3; }
.post-featured__body h2 a { color: var(--text); }
.post-featured__body p { margin: 0; }
@media (max-width: 760px) { .post-featured { grid-template-columns: 1fr; } .post-featured__media { aspect-ratio: 16 / 9; min-height: 0; } }

/* ---- single post ----------------------------------------------------- */
.post__header { padding-top: var(--sp-7); }
.post__header h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); line-height: 1.2; letter-spacing: -0.028em; margin: var(--sp-2) 0 var(--sp-3); }
.post__lead { font-size: 1.2rem; color: var(--text-muted); line-height: 1.6; }
.post__byline { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4) 0; border-bottom: 1px solid var(--border); }
.post__byline > div { display: flex; flex-direction: column; }
.post__cover { margin: var(--sp-6) auto 0; max-width: 1000px; }
.post__cover img { width: 100%; height: auto; border-radius: var(--r-xl); display: block; }

.post__layout {
  display: grid; grid-template-columns: 220px minmax(0, 760px); justify-content: center; gap: var(--sp-8);
  padding-block: var(--sp-7) var(--sp-9);
}
.post__layout > .post__main:only-child { grid-column: 1 / -1; max-width: 760px; margin-inline: auto; width: 100%; }
.post__toc { position: sticky; top: 84px; align-self: start; font-size: var(--fs-sm); }
.post__toc-title { font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; font-size: var(--fs-xs); color: var(--text-subtle); }
.post__toc ol { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.post__toc li a { display: block; padding: 6px 0 6px var(--sp-3); margin-left: -2px; border-left: 2px solid transparent; color: var(--text-muted); }
.post__toc li a:hover { color: var(--brand-text); border-left-color: var(--brand-500); text-decoration: none; }
@media (max-width: 1000px) {
  .post__layout { grid-template-columns: minmax(0, 1fr); }
  .post__toc { position: static; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4); }
}

.post__share { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-6); padding-top: var(--sp-5); border-top: 1px solid var(--border); }
.post__share > span { margin-right: var(--sp-2); }
.post__cta { margin-top: var(--sp-6); background: linear-gradient(150deg, var(--brand-50), var(--surface)); }
:root[data-theme="dark"] .post__cta { background: var(--surface); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .post__cta { background: var(--surface); } }
.post__adjacent { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); margin-top: var(--sp-6); }
.post__adjacent a { display: flex; flex-direction: column; gap: 4px; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); color: var(--text); font-weight: 600; }
.post__adjacent a:hover { border-color: var(--brand-400); text-decoration: none; }
.post__adjacent a.right { align-items: flex-end; }
@media (max-width: 620px) { .post__adjacent { grid-template-columns: 1fr; } }

/* ---- about ----------------------------------------------------------- */
.about-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-4);
  margin-top: calc(var(--sp-6) * -1); position: relative; padding-top: var(--sp-8);
}
.about-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: var(--sp-5); box-shadow: var(--sh-sm); }
.about-stat strong { display: block; font-size: var(--fs-2xl); letter-spacing: -0.02em; color: var(--brand-text); }
.about-stat span { color: var(--text-muted); font-size: var(--fs-sm); }
.about-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-8); padding-block: var(--sp-8) var(--sp-6); }
.about-aside { display: grid; gap: var(--sp-4); align-content: start; }
.about-values { list-style: none; margin: 0; padding: var(--sp-2) var(--sp-5) var(--sp-4); display: grid; gap: var(--sp-4); }
.about-values li { display: flex; gap: var(--sp-3); color: var(--brand-text); }
.about-values li div { display: flex; flex-direction: column; color: var(--text); }
.about-values li span { color: var(--text-muted); font-size: var(--fs-sm); }
@media (max-width: 960px) { .about-layout { grid-template-columns: 1fr; } }

/* ---- contact --------------------------------------------------------- */
.contact-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--sp-7); padding-block: var(--sp-7) var(--sp-9); scroll-margin-top: 80px; }
.contact-aside { display: grid; gap: var(--sp-3); align-content: start; }
.contact-method {
  display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); color: var(--text);
}
a.contact-method:hover { border-color: var(--brand-400); text-decoration: none; box-shadow: var(--sh-sm); }
.contact-method > span:last-child { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.contact-method > span:last-child span { color: var(--text-muted); font-size: var(--fs-sm); }
.contact-method__icon {
  flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: var(--r-md);
  background: var(--brand-50); color: var(--brand-text);
}
:root[data-theme="dark"] .contact-method__icon { background: var(--surface-3); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .contact-method__icon { background: var(--surface-3); } }
.contact-done { text-align: center; }
.contact-done .card__body { padding: var(--sp-8) var(--sp-6); display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); }
.contact-done h2 { margin: 0; }
.contact-done p { max-width: 52ch; }
.contact-done__icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--success-bg); color: var(--success-fg); }
@media (max-width: 960px) { .contact-layout { grid-template-columns: 1fr; } }
.blog-hero .chip-row { margin-top: var(--sp-5); }
