/* ==========================================================
   Marioneta — Design System
   Shared UI contract: primitives → components → patterns.
   Loaded after tokens.css and route-local styles.
   ========================================================== */

/* ── RESET & BASE ──────────────────────────────────────────── */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ── FOCUS ─────────────────────────────────────────────────── */
:where(a, button, input, textarea, select):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

/* ── LAYOUT PRIMITIVES ─────────────────────────────────────── */
:where(.wrap, .container, .shell) {
  width: min(var(--content), calc(100% - var(--page-gutter) * 2));
  margin-inline: auto;
}
:where(.reading) {
  width: min(var(--reading), calc(100% - var(--page-gutter) * 2));
  margin-inline: auto;
}
:where(.wide) {
  width: min(var(--wide), calc(100% - var(--page-gutter) * 2));
  margin-inline: auto;
}

/* ── TYPOGRAPHY PRIMITIVES ─────────────────────────────────── */
:where(.eyebrow, .section-label) {
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brand-primary);
  font-weight: 700;
}
:where(.lede) {
  font-size: clamp(17px, 1.3vw, 18px);
  line-height: 1.7;
  color: var(--text-secondary);
}
:where(h1) { font-size: clamp(36px, 4vw, 56px); line-height: 1.08; text-wrap: balance; }
:where(h2) { font-size: clamp(28px, 2.7vw, 36px); line-height: 1.15; text-wrap: balance; }
:where(h3) { font-size: clamp(20px, 1.8vw, 24px); line-height: 1.25; }

/* ── NAVIGATION (hubnav) ───────────────────────────────────── */
.hubnav {
  position: relative;
  left: 50%;
  width: min(1180px, calc(100vw - 32px));
  max-width: none;
  min-height: 62px;
  margin: 0;
  padding: 18px 0 0;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-inline: contain;
}
.hubnav::-webkit-scrollbar { display: none; }
.hubnav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  transition: border-color .15s, color .15s;
}
.hubnav a:hover { border-color: var(--brand-secondary); color: var(--text-primary); }
.hubnav a[aria-current="page"] { border-color: var(--brand-primary); color: var(--brand-primary); background: rgba(188,152,92,.08); }
.hubnav a.hubnav-cta {
  background: var(--brand-gradient);
  color: var(--text-inverse);
  border-color: transparent;
  font-weight: 700;
  padding-inline: 20px;
}
.hubnav a.hubnav-cta:hover { border-color: transparent; }

.site-header__brand {
  flex: 0 0 auto;
  margin-right: var(--space-3);
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .08em;
  text-decoration: none;
}
.site-header__toggle { display: none; }

/* Theme toggle button */
.site-header__theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .15s, color .15s;
}
.site-header__theme-toggle:hover { border-color: var(--brand-secondary); color: var(--text-primary); }
@media (max-width: 1100px) {
  .site-header__theme-toggle { display: none; }
}

/* ── HEADER (mobile) ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .hubnav {
    width: calc(100vw - 24px);
    min-height: 60px;
    padding-block: 8px;
    scroll-snap-type: inline proximity;
  }
  .hubnav a { min-height: 44px; scroll-snap-align: start; }
  .site-header__brand { margin-right: auto; }
  .site-header__toggle {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    background: var(--surface-card);
    color: var(--text-primary);
    font: 600 14px/20px var(--sans);
    cursor: pointer;
  }
  .site-header:not([data-open]) > a:not(.site-header__brand) { display: none; }
  .site-header[data-open] {
    position: relative;
    flex-wrap: wrap;
    overflow: visible;
    padding-bottom: var(--space-4);
  }
  .site-header[data-open] > a {
    width: 100%;
    justify-content: flex-start;
    border-color: var(--border-default);
  }
  .site-header[data-open] > .site-header__brand { width: auto; }
}

/* ── BUTTONS ───────────────────────────────────────────────── */
.cta, .button, .btn-ad {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-inline: 24px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  border: none;
}
.cta-primary, .cta {
  background: var(--brand-gradient);
  color: var(--text-inverse);
  box-shadow: 0 8px 24px -8px rgba(188,152,92,.45);
}
.cta-primary:hover, .cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px -8px rgba(188,152,92,.55);
}
.cta-secondary {
  background: transparent;
  color: var(--brand-primary);
  border: 1px solid var(--border-default);
  padding: 15px 27px;
  box-shadow: none;
}
.cta-secondary:hover { border-color: var(--brand-secondary); }
.cta-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 8px 0; }

/* ── CARDS ─────────────────────────────────────────────────── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card--compact { padding: 16px; }
.card--large { padding: 32px 24px; }

/* ── TAGS ──────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 5px 11px;
  background: var(--pill-bg);
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
}

/* ── NEWSLETTER ────────────────────────────────────────────── */
.newsletter {
  max-width: 460px;
  margin: 0 auto var(--space-6);
  text-align: center;
  padding: var(--space-6);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
}
.newsletter .eyebrow { margin-bottom: 6px; }
.newsletter-sub { color: var(--text-secondary); font-size: 13.5px; margin: 0 0 16px; }
.newsletter-form { display: flex; flex-direction: column; gap: 10px; }
.newsletter-form input {
  min-height: 44px;
  font-size: 16px;
  background: var(--surface-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: 13px 16px;
  color: var(--text-primary);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}
.newsletter-form input::placeholder { color: var(--text-muted); }
.newsletter-form button {
  min-height: 44px;
  background: var(--brand-gradient);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px 18px;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  font-family: inherit;
}
.newsletter-form button:disabled { opacity: .6; cursor: default; }
.newsletter-consent { display: flex; align-items: flex-start; gap: 8px; text-align: left; font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.newsletter-consent input { margin-top: 2px; flex: 0 0 auto; }
.newsletter-error { color: var(--error); font-size: 12.5px; min-height: 16px; margin-top: 8px; }
.newsletter-success { color: var(--brand-secondary); font-size: 13.5px; margin-top: 8px; font-weight: 600; }

/* ── FOOTER ────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border-default);
  margin-top: var(--space-8);
  padding-block: var(--space-6);
}
.sitefooter {
  border-top: 1px solid var(--border-default);
  padding: 40px 0 48px;
  margin-top: 10px;
}
.sitefooter .links, .site-footer .links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin-bottom: 16px;
}
.sitefooter .links a, .site-footer .links a {
  color: var(--text-secondary);
  font-size: 13.5px;
  text-decoration: none;
}
.sitefooter .links a:hover, .site-footer .links a:hover { color: var(--brand-primary); }
.sitefooter .contact, .site-footer .contact {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.sitefooter .contact a, .site-footer .contact a { color: var(--text-secondary); text-decoration: underline; }
.sitefooter .tiny, .site-footer .tiny {
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 16px;
}

/* ── MARIONETTE ANIMATION ──────────────────────────────────── */
.marionette {
  position: relative;
  height: 170px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  margin: 8px 0 6px;
}
.marionette svg { height: 100%; overflow: visible; }
.m-hand  { transform-origin: 96px 20px;  animation: handSway   9s  ease-in-out infinite; animation-delay: -1.3s; }
.m-bar   { transform-origin: 96px 34px;  animation: barTilt    7s  ease-in-out infinite; animation-delay: -2.6s; }
.m-figure { transform-origin: 96px 92px; animation: figureSway 11s ease-in-out infinite; animation-delay: -4.1s; }
.m-armL  { transform-origin: 78px 96px;  animation: armL       6.5s ease-in-out infinite; animation-delay: -0.7s; }
.m-armR  { transform-origin: 114px 96px; animation: armR       8.3s ease-in-out infinite; animation-delay: -3.4s; }
.m-legL  { transform-origin: 88px 132px; animation: legL       7.7s ease-in-out infinite; animation-delay: -5.2s; }
.m-legR  { transform-origin: 104px 132px; animation: legR      6.1s ease-in-out infinite; animation-delay: -1.9s; }

@keyframes handSway {
  0%,100% { transform: rotate(-4deg) translateX(0); }
  33%     { transform: rotate(3deg) translateX(5px); }
  66%     { transform: rotate(-2deg) translateX(-4px); }
}
@keyframes barTilt {
  0%,100% { transform: rotate(-6deg); }
  45%     { transform: rotate(6.5deg); }
  75%     { transform: rotate(-3deg); }
}
@keyframes figureSway {
  0%,100% { transform: rotate(-3deg) translateY(0); }
  40%     { transform: rotate(3.4deg) translateY(4px); }
  70%     { transform: rotate(-1.6deg) translateY(-2px); }
}
@keyframes armL  { 0%,100% { transform: rotate(11deg); }  50% { transform: rotate(-15deg); } }
@keyframes armR  { 0%,100% { transform: rotate(-13deg); } 55% { transform: rotate(14deg); } }
@keyframes legL  { 0%,100% { transform: rotate(-7deg); }  50% { transform: rotate(10deg); } }
@keyframes legR  { 0%,100% { transform: rotate(9deg); }   45% { transform: rotate(-9deg); } }

/* ── AD SLOTS (hidden by default) ──────────────────────────── */
.mn-rail, .mn-mobile-strip--bottom, .ad-slot--partner:not(:has(ins[data-ad-slot])) { display: none !important; }
.ad-slot { margin-block: 48px; }
.ad-slot-label { color: var(--text-muted) !important; font-size: 12px !important; letter-spacing: .08em !important; }

/* ── SKIP LINK ─────────────────────────────────────────────── */
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 1000;
  background: var(--brand-primary); color: var(--text-inverse); font-weight: 700;
  padding: 12px 18px; border-radius: 8px; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 479px) {
  :where(.wrap, .container, .shell, .reading, .wide) { width: calc(100% - 32px); }
}
@media (min-width: 1440px) {
  .mn-page-grid { display: grid; grid-template-columns: 224px minmax(0, 840px) 224px; gap: 40px; width: min(var(--wide), calc(100% - 80px)); margin-inline: auto; }
}
@media (max-width: 680px) {
  .platform-list { grid-template-columns: 1fr; }
}

/* ── REDUCED MOTION ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .m-hand, .m-bar, .m-figure, .m-armL, .m-armR, .m-legL, .m-legR { animation: none !important; }
}
