/* =========================================================================
   TreeNodes — global base styles, shared components, motion.
   Design tokens live in /src/styles/tokens.css (imported by Layout.astro).
   Only tokens + genuinely shared rules live here; page/section layout
   lives in each page's scoped <style> block.
   ========================================================================= */

/* ---- Reset / base ------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: var(--color-text);
  text-decoration: none;
}
a:hover {
  color: var(--color-accent);
}

img,
svg {
  display: block;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 500;
}

:focus-visible {
  outline: 2px solid var(--pg-purple);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Page shell (header + main + footer, footer pinned to bottom) */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1 0 auto;
  width: 100%;
}

/* Shared content width */
.container {
  max-width: 1140px;
  margin-inline: auto;
  padding-inline: 32px;
  width: 100%;
  box-sizing: border-box;
}

/* ---- Theme-aware logo / icon swapping ----------------------------------- */
html[data-theme="light"] [data-logo="dark"] {
  display: none !important;
}
html:not([data-theme="light"]) [data-logo="light"] {
  display: none !important;
}
html[data-theme="light"] [data-icon="sun"] {
  display: none !important;
}
html:not([data-theme="light"]) [data-icon="moon"] {
  display: none !important;
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn i {
  font-size: 1.05em;
  line-height: 0;
}

.btn.btn-primary {
  background: var(--color-text);
  border-color: var(--color-text);
  color: var(--color-bg);
}
.btn.btn-primary:hover {
  background: color-mix(in srgb, var(--color-text) 84%, var(--color-bg));
  border-color: color-mix(in srgb, var(--color-text) 84%, var(--color-bg));
  color: var(--color-bg);
}
.btn.btn-primary:active {
  background: color-mix(in srgb, var(--color-text) 70%, var(--color-bg));
  color: var(--color-bg);
}

.btn.btn-secondary {
  background: none;
  border: 1px solid var(--pg-border);
  color: var(--color-text);
}
.btn.btn-secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.btn.btn-block {
  width: 100%;
}

/* ---- Form fields (Contact) --------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  color: var(--pg-muted);
}
.input {
  width: 100%;
  box-sizing: border-box;
  background: color-mix(in srgb, var(--color-surface) 45%, transparent);
  border: 1px solid var(--pg-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color 0.2s;
}
.input::placeholder {
  color: var(--pg-muted);
}
.input:focus {
  outline: 2px solid var(--pg-purple);
  outline-offset: 2px;
  border-color: transparent;
}

/* ---- Small shared bits -------------------------------------------------- */
.kicker {
  font-size: 13px;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--pg-muted);
  letter-spacing: 0.06em;
  font-weight: 500;
}
.eyebrow .pill {
  display: inline-flex;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: 11.5px;
  letter-spacing: 0.01em;
}
.pill-purple {
  background: color-mix(in srgb, var(--pg-purple) 15%, transparent);
  color: var(--pg-purple);
}
.pill-coral {
  background: color-mix(in srgb, var(--pg-red) 15%, transparent);
  color: var(--pg-red);
}

/* ---- Entrance reveal ---------------------------------------------------- */
[data-reveal] {
  animation: tnRise 0.85s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.rise {
  animation: tnRise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.rise-slow {
  animation: tnRise 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.rise-d1 { animation-delay: 0.08s; }
.rise-d2 { animation-delay: 0.16s; }
.rise-d3 { animation-delay: 0.2s; }
.rise-d4 { animation-delay: 0.24s; }
.rise-d5 { animation-delay: 0.32s; }

/* ---- Keyframes (ported from the handoff) -------------------------------- */
@keyframes tnRise {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: none; }
}
@keyframes tnFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes tnFloatSm {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
@keyframes tnPulse {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}
@keyframes tnDash {
  to { stroke-dashoffset: -240; }
}
@keyframes tnGrow {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
@keyframes tnGlow {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pg-green) 45%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--pg-green) 0%, transparent); }
}
@keyframes tnDraw {
  0%   { stroke-dashoffset: 1; opacity: 0; }
  10%  { opacity: 1; }
  50%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes tnBreathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}
@keyframes tnSpin {
  to { transform: rotate(360deg); }
}
@keyframes tnTravel {
  0%   { top: 0; opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { top: calc(100% - 44px); opacity: 0; }
}

/* ---- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal],
  .rise,
  .rise-slow {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  border-bottom: 1px solid var(--pg-border);
}
.header-inner {
  padding-block: 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-text);
  justify-self: start;
}
.brand-name {
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.dot {
  color: var(--pg-red);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 14px;
  justify-self: center;
}
.nav-links a {
  color: var(--pg-muted);
}
.nav-links a:hover,
.nav-links a[aria-current='page'] {
  color: var(--color-text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-self: end;
}

/* ---- Mobile menu ---- */
/* .theme-toggle.menu-toggle: the extra class outranks the later
   .theme-toggle { display:inline-flex } rule this button also carries. */
.theme-toggle.menu-toggle {
  display: none;
}
.mobile-nav {
  display: none;
}
/* Icon swap lives outside the media query so both icons can never show at
   once, whatever the viewport. */
.menu-toggle .menu-close-icon {
  display: none;
}
.site-header.menu-open .menu-toggle .menu-open-icon {
  display: none;
}
.site-header.menu-open .menu-toggle .menu-close-icon {
  display: block;
}

@media (max-width: 820px) {
  .header-inner {
    grid-template-columns: 1fr auto;
  }
  .nav-links {
    display: none;
  }
  .theme-toggle.menu-toggle {
    display: inline-flex;
  }
  .site-header.menu-open .mobile-nav {
    display: flex;
    flex-direction: column;
    padding: 4px 32px 16px;
    border-top: 1px solid var(--pg-border);
  }
  .mobile-nav a {
    padding: 12px 0;
    font-size: 15px;
    color: var(--pg-muted);
    border-bottom: 1px solid color-mix(in srgb, var(--pg-border) 55%, transparent);
  }
  .mobile-nav a:last-child {
    border-bottom: none;
  }
  .mobile-nav a:hover,
  .mobile-nav a[aria-current='page'] {
    color: var(--color-text);
  }
}

@media (max-width: 560px) {
  .container {
    padding-inline: 20px;
  }
  .site-header.menu-open .mobile-nav {
    padding-inline: 20px;
  }
  .nav-actions {
    gap: 10px;
  }
}

.site-footer {
  border-top: 1px solid var(--pg-border);
  margin-top: auto;
}
.footer-inner {
  padding-block: 56px 44px;
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr;
  gap: 48px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 36ch;
}
.footer-brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text);
}
.footer-brand-row .brand-name {
  font-weight: 500;
  font-size: 15px;
}

.footer-socials {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 18px;
}
.footer-socials a {
  color: var(--pg-muted);
}
.footer-socials a:hover {
  color: var(--pg-red);
}

.footer-line {
  margin: 2px 0 0;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--color-text);
}
.footer-line span {
  color: var(--pg-red);
}
.footer-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--pg-muted);
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}
.footer-col-title {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--pg-muted);
  font-weight: 500;
}
.footer-col a {
  color: var(--color-text);
}
.footer-col a:hover {
  color: var(--color-accent);
}

.footer-legal {
  border-top: 1px solid var(--pg-border);
}
.footer-legal-inner {
  padding-block: 18px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--pg-muted);
}

@media (max-width: 820px) {
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
  .footer-brand {
    grid-column: 1 / -1;
  }
}
@media (max-width: 520px) {
  .footer-inner {
    grid-template-columns: 1fr;
  }
}

.theme-toggle {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--pg-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.theme-toggle:hover {
  border-color: var(--color-accent);
}

/* ---- Scroll reveal ----
   Reveal motion itself is driven by Motion springs (src/scripts/reveal.js),
   which animates opacity/translate inline. CSS only sets the hidden initial
   state (no transition — it would fight Motion's per-frame updates) and a
   final-state fallback in case the script never runs on a revealed element. */
html.sr-on [data-sr] { opacity: 0; transform: translateY(18px); }
html.sr-on [data-sr].sr-in { opacity: 1; transform: none; }
