/*
  Shared components: header, footer, buttons, forms, badges, toggles.
  Built entirely on tokens from tokens.css, so when the homepage swaps
  --surface/--ink/--accent/etc. via a home-style override, these components
  re-theme automatically without any component-level overrides needed here.
*/

/* Header ---------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: var(--border-w) solid var(--line);
}

/*
  The translucent blur lives on a pseudo-element, not on .site-header itself. backdrop-filter (like
  transform/filter) creates a new containing block for position: fixed descendants — and the mobile
  nav panel (.site-nav below, position: fixed at that breakpoint) is a descendant of this header.
  With backdrop-filter directly on .site-header, the "fixed" nav was positioning itself relative to
  the ~68px-tall header box instead of the viewport, collapsing the open menu to a sliver. Found this
  via an actual mobile-nav screenshot, not by inspection — keep the blur off this element.
*/
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.nav-shell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-block: 16px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  /* .brand-cluster has min-width: 0 (needed so its siblings can shrink/wrap), which also lets this
     shrink below its natural size — and since only the image's height is fixed in CSS, a flex
     squeeze compresses width only, distorting the logo's aspect ratio. flex-shrink: 0 keeps the
     whole logo at its intrinsic size no matter how tight the header gets. */
  flex-shrink: 0;
}

.brand-logo img {
  height: 30px;
  width: auto;
}

/*
  Default (light) state hides every logo-dark variant, not just .brand-logo's — .mark-swap and
  .footer-logo-mark used to get this for free from each theme's own "pin to light" override, but
  those pins only existed in themes with no real dark-mode support of their own. Once Atelier,
  Editorial, and Playful each gained a genuine dark mode and had their pins removed (so the toggle
  could actually take effect), nothing was left hiding .mark-swap/.footer-logo-mark's logo-dark by
  default — img's UA/base.css default is display:block, so with no rule to hide it, both the light
  and dark logo variants rendered stacked on top of each other simultaneously in light mode. Studio
  (the bare :root default, no per-theme pin of its own ever) had the exact same gap. Glass Noir is
  the only style unaffected, since it carries its own full pin (see home-glass.css) that always wins
  on specificity regardless of this rule.
*/
.brand-logo .logo-dark,
.footer-logo-mark .logo-dark,
.mark-swap .logo-dark {
  display: none;
}

[data-theme="dark"] .brand-logo .logo-light,
[data-theme="dark"] .footer-logo-mark .logo-light,
[data-theme="dark"] .mark-swap .logo-light {
  display: none;
}

[data-theme="dark"] .brand-logo .logo-dark,
[data-theme="dark"] .footer-logo-mark .logo-dark,
[data-theme="dark"] .mark-swap .logo-dark {
  display: block;
}

.design-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 14px;
  border-left: var(--border-w) solid var(--line);
}

.style-label {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .style-label {
    display: none;
  }
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 30px;
  font-size: 0.94rem;
  font-weight: 500;
}

.site-nav a {
  position: relative;
  padding-block: 4px;
  color: var(--ink-soft);
  transition: color var(--dur-fast) var(--ease);
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -2px;
  height: 2px;
  background: var(--accent);
  transition: right var(--dur-normal) var(--ease);
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a[aria-current="page"] {
  color: var(--ink);
}

.site-nav a:hover::after,
.site-nav a:focus-visible::after,
.site-nav a[aria-current="page"]::after {
  right: 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.icon-button:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.icon-button:active {
  transform: scale(0.94);
}

.icon-button .icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-design-button.is-attention {
  color: var(--accent);
  animation: attention-pulse 1.8s ease-in-out infinite;
}

@keyframes attention-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent);
  }
  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

/*
  Segmented EN|ES switch. One shared rule set for all 5 home styles plus every inner page — each
  theme already redefines --surface-alt/--line/--accent/--on-accent/--radius-pill, so this re-skins
  automatically for free, no per-theme override needed.
*/
.lang-switch {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  border: var(--border-w) solid var(--line);
}

.lang-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  bottom: 3px;
  width: calc(50% - 3px);
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: transform var(--dur-normal) var(--ease);
}

.lang-switch.is-es::before {
  transform: translateX(100%);
}

.lang-switch button {
  position: relative;
  z-index: 1;
  min-width: 30px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
  transition: color var(--dur-fast) var(--ease);
}

.lang-switch button.is-active {
  color: var(--on-accent);
}

.theme-toggle .icon-moon,
.theme-toggle .icon-system {
  display: none;
}

[data-theme-mode="dark"] .theme-toggle .icon-sun,
[data-theme-mode="system"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme-mode="dark"] .theme-toggle .icon-moon {
  display: block;
}

[data-theme-mode="system"] .theme-toggle .icon-system {
  display: block;
}

.menu-toggle {
  display: none;
}

.menu-toggle .icon-close {
  display: none;
}

body.nav-open .menu-toggle .icon-menu {
  display: none;
}

body.nav-open .menu-toggle .icon-close {
  display: block;
}

@media (max-width: 860px) {
  .menu-toggle {
    display: inline-flex;
  }

  .site-nav {
    position: fixed;
    inset: 68px 0 0 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px var(--container-pad) 28px;
    background: var(--surface);
    border-top: var(--border-w) solid var(--line);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-normal) var(--ease), transform var(--dur-normal) var(--ease), visibility var(--dur-normal);
    overflow-y: auto;
  }

  body.nav-open .site-nav {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }

  .site-nav a {
    padding-block: 14px;
    border-bottom: var(--border-w) solid var(--line);
    font-size: 1.05rem;
  }

  .site-nav a::after {
    display: none;
  }
}

/*
  Below 860px, .site-nav goes position:fixed and drops out of normal flow, leaving only
  .brand-cluster and .nav-actions as .nav-shell's flex children. Their combined intrinsic width
  (logo + style label/dice/reset + lang-switch + theme/menu buttons) is wider than most phone
  viewports, so without shrinking they overlap instead of wrapping (flex nowrap by default) —
  found via Playwright reporting the dice button as un-clickable, occluded by the lang-switch.
  This tightens spacing/sizing enough to fit single-row on real phone widths (measured, not
  guessed) and hides the reset button, whose job the dice button already does eventually by
  cycling back to default.
*/
@media (max-width: 640px) {
  .nav-shell {
    padding-inline: 16px;
  }

  .brand-logo img {
    height: 26px;
  }

  .brand-cluster {
    gap: 10px;
  }

  .design-controls {
    padding-left: 0;
    border-left: none;
    gap: 4px;
  }

  .home-design-button.design-reset {
    display: none;
  }

  .nav-actions {
    gap: 4px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .lang-switch button {
    min-width: 26px;
    padding: 5px 7px;
  }
}

/* Buttons ---------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 26px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.button .icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--dur-fast) var(--ease);
}

.button:hover .icon {
  transform: translateX(3px);
}

.button-primary {
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow-sm);
}

.button-primary:hover {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.button-secondary {
  background: transparent;
  color: var(--ink);
  border: var(--border-w) solid var(--line-strong);
}

.button-secondary:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.button-small {
  padding: 9px 18px;
  font-size: 0.85rem;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* Forms ------------------------------------------------------------------ */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field small {
  font-weight: 400;
  color: var(--ink-faint);
  text-transform: none;
  letter-spacing: normal;
}

.field input,
.field textarea {
  width: 100%;
  padding: 13px 16px;
  background: var(--surface-elevated);
  border: var(--border-w) solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 0.98rem;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.form-error {
  min-height: 1.2em;
  font-size: 0.86rem;
  color: var(--danger);
}

.form-status {
  min-height: 1.2em;
  font-size: 0.84rem;
  color: var(--ink-faint);
}

.form-status.is-error {
  color: var(--danger);
}

/* Badges / cards ---------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card {
  background: var(--surface-elevated);
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.check-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.98rem;
}

/*
  Generic "this slot is a placeholder" treatment for the work-examples grid — theme-agnostic on
  purpose (dashed border + reduced opacity reads as "empty slot" against any of the 5 palettes
  without needing a per-theme override), used for the real-project cards not yet filled in.
*/
.work-card.is-placeholder {
  border-style: dashed;
  opacity: 0.68;
  cursor: default;
}

.work-card.is-placeholder:hover {
  opacity: 0.9;
  transform: none !important;
  box-shadow: none !important;
}

.work-card.is-placeholder .work-title {
  font-style: italic;
}

.check-list .icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  padding: 3px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
  border-top: var(--border-w) solid var(--line);
  padding-block: 40px;
  background: var(--surface-alt);
}

.footer-panel {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 48px;
}

.footer-intro {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 380px;
}

.footer-brand img {
  height: 26px;
}

.footer-intro p {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.footer-small-links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.footer-small-links a {
  color: var(--ink-soft);
  transition: color var(--dur-fast) var(--ease);
}

.footer-small-links a:hover {
  color: var(--accent);
}

.footer-contact {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  justify-content: center;
}

.footer-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 0.95rem;
}

.footer-line span {
  color: var(--ink-faint);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}

.footer-line a,
.footer-cta {
  color: var(--ink);
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease);
}

.footer-line a:hover,
.footer-cta:hover {
  color: var(--accent);
}

@media (max-width: 720px) {
  .footer-panel {
    grid-template-columns: 1fr;
  }
}

/* Page hero (used by every non-home page) --------------------------------- */

.page-hero {
  padding-block: clamp(36px, 5vw, 64px) clamp(24px, 4vw, 40px);
}

.page-hero .container > * + * {
  margin-top: 16px;
}

.page-hero h1 {
  max-width: 760px;
}

.page-hero p:not(.eyebrow) {
  max-width: 620px;
  color: var(--ink-soft);
  font-size: 1.08rem;
}

/* Mobile tap-signal (site.js's setupTapSignal) ----------------------------- */
/*
  Deliberately theme-agnostic (unlike the Glass-Noir-only cursor-trail in home-glass.css) — this
  lives here, not in a per-style file, so var(--accent) picks up whichever of the five home styles is
  currently active with zero extra wiring. left/top are set directly in px by site.js on each touch;
  the animation only plays while .is-active is present, restarted via a forced reflow in JS so rapid
  repeated taps each get their own ping instead of the first tap's animation just running once.
*/
.tap-signal {
  position: fixed;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 35;
  opacity: 0;
}

.tap-signal.is-active {
  animation: tap-signal-ping 550ms var(--ease);
}

@keyframes tap-signal-ping {
  0% {
    opacity: 0.85;
    transform: scale(0.4);
  }
  35% {
    opacity: 0.5;
    transform: scale(1.1);
  }
  100% {
    opacity: 0;
    transform: scale(2.4);
  }
}
