/*
  Satori brand layer: loaded last on every page.
  Identity: sumi ink, warm paper, one vermilion seal (shu).
  Shape rule: interactive controls are pills, containers 14px, inner panels/code 8px.
  Motion rule: things come into focus (blur -> sharp), ink draws itself, the seal stamps once.
*/
:root {
  --ink-0: #0b0b0c;
  --ink-1: #111113;
  --ink-2: #17171a;
  --ink-3: #202024;
  --paper: #edeae3;
  --paper-rgb: 237, 234, 227;
  --paper-2: rgba(237, 234, 227, 0.7);
  --paper-3: rgba(237, 234, 227, 0.5);
  --shu: #e5553b;
  --shu-rgb: 229, 85, 59;
  --shu-hi: #ef6a50;
  --shu-soft: rgba(229, 85, 59, 0.14);
  --line: rgba(237, 234, 227, 0.08);
  --line-strong: rgba(237, 234, 227, 0.16);

  /* Legacy tokens used by site.css and page styles, remapped to the brand. */
  --bg: var(--ink-0);
  --fg: var(--paper);
  --muted: var(--paper-2);
  --muted-soft: var(--paper-3);
  --accent: var(--shu);
  --accent-rgb: var(--shu-rgb);
  --accent-dim: var(--shu-soft);
  --cyan: #c9c1b2;
  --cyan-rgb: 201, 193, 178;
  --cyan-dim: rgba(201, 193, 178, 0.1);
  --violet: #c9c1b2;
  --pink: var(--shu);
  --warm: var(--shu-hi);
  --panel: rgba(17, 17, 19, 0.82);
  --panel-raised: rgba(23, 23, 26, 0.94);
  --panel-soft: rgba(237, 234, 227, 0.025);

  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --serif: var(--display);
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --shadow-soft: 0 24px 60px -24px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.3);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-ink: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-stamp: cubic-bezier(0.34, 1.56, 0.64, 1);

  --z-grain: 60;
  --z-nav: 40;
  --z-float: 30;
}

html {
  background: var(--ink-0);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Decorative ensō marks bleed past the layout; clip (not hidden) keeps sticky nav working. */
  overflow-x: clip;
}

/* Touch: no grey tap flash (every control has its own :active), no double-tap delay,
   and long-press never selects a control's label. Body text stays selectable. */
html {
  -webkit-tap-highlight-color: transparent;
}

a,
button,
[role="tab"] {
  touch-action: manipulation;
}

button,
.btn,
[role="tab"] {
  -webkit-user-select: none;
  user-select: none;
}

body {
  color: var(--paper);
  font-family: var(--sans);
  background-color: var(--ink-0);
  background-image:
    radial-gradient(ellipse 70% 45% at 82% -8%, rgba(229, 85, 59, 0.07) 0%, transparent 62%),
    radial-gradient(ellipse 60% 50% at 0% 30%, rgba(237, 234, 227, 0.035) 0%, transparent 60%);
  background-attachment: fixed;
}

/* Paper grain: fixed and pointer-transparent so scrolling never repaints it. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  mask-image: none;
  background-size: 180px 180px;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

body::after {
  content: none;
}

.grain-overlay,
.vignette,
.bg-grid,
.ambient-energy,
.ambient-wisp {
  display: none !important;
}

::selection {
  background: var(--shu);
  color: var(--ink-0);
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--shu);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-0);
  font-weight: 600;
  text-decoration: none;
  transition: top 200ms var(--ease-out);
}

.skip-link:focus {
  top: 1rem;
}

/* ---------- Ensō mark ---------- */
.enso {
  display: block;
  color: var(--paper);
  overflow: visible;
}

.enso-seal {
  fill: var(--shu);
  transform-box: fill-box;
  transform-origin: center;
  transform: rotate(-5deg);
}

@media (prefers-reduced-motion: no-preference) {
  .enso.is-drawing .enso-trace {
    stroke-dasharray: 1 1;
    stroke-dashoffset: 1;
    animation: enso-draw var(--enso-dur, 1.25s) var(--ease-ink) var(--enso-delay, 0s) forwards;
  }

  .enso.is-drawing .enso-seal {
    opacity: 0;
    animation: seal-stamp 420ms var(--ease-stamp) calc(var(--enso-delay, 0s) + var(--enso-dur, 1.25s) - 0.12s) forwards;
  }
}

@keyframes enso-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes seal-stamp {
  0% { opacity: 0; transform: rotate(-18deg) scale(1.9); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: rotate(-5deg) scale(1); }
}

/* ---------- Navigation ---------- */
.container {
  width: min(100%, 1240px);
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.9rem clamp(1rem, 3vw, 1.5rem) 3rem;
  position: relative;
  z-index: 1;
}

nav[aria-label="Primary"] {
  position: sticky;
  top: 0.75rem;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 60px;
  padding: 0.45rem 0.5rem 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(17, 17, 19, 0.72);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: inset 0 1px 0 rgba(237, 234, 227, 0.05), 0 12px 32px -16px rgba(0, 0, 0, 0.8);
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--paper);
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
.nav-brand:hover {
  color: var(--paper);
}
}

.nav-brand-logo,
.nav-brand .enso {
  width: 34px;
  height: 34px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-links a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0.5rem 0.9rem;
  border: 0;
  border-radius: 999px;
  color: var(--paper-2);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  white-space: nowrap;
  transition: color 180ms var(--ease-out), background-color 180ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
.nav-links a:hover {
  color: var(--paper);
  background: rgba(237, 234, 227, 0.06);
  border-color: transparent;
}
}

.nav-links a[aria-current="page"] {
  color: var(--paper);
}

.nav-links a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 1px;
  background: var(--shu);
}

.nav-links a.cta-contact {
  margin-left: 0.35rem;
  color: var(--ink-0);
  background: var(--paper);
  font-weight: 600;
  box-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
.nav-links a.cta-contact:hover {
  color: var(--ink-0);
  background: #fff8ee;
  box-shadow: none;
}
}

/* ---------- Buttons ---------- */
.btn,
.contact-subject,
.copy-btn {
  font-family: var(--sans);
  letter-spacing: 0;
  text-transform: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 48px;
  padding: 0.8rem 1.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(237, 234, 227, 0.03);
  color: var(--paper);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition:
    transform 160ms var(--ease-out),
    background-color 200ms var(--ease-out),
    border-color 200ms var(--ease-out),
    color 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
.btn:hover {
  border-color: rgba(237, 234, 227, 0.32);
  background: rgba(237, 234, 227, 0.07);
  color: var(--paper);
  box-shadow: none;
  transform: none;
}
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  border-color: var(--shu);
  background: var(--shu);
  color: #140806;
  font-weight: 600;
  box-shadow: 0 10px 30px -12px rgba(229, 85, 59, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

@media (hover: hover) and (pointer: fine) {
.btn.primary:hover {
  border-color: var(--shu-hi);
  background: var(--shu-hi);
  color: #140806;
}
}

.btn .btn-arrow {
  transition: transform 220ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
.btn:hover .btn-arrow {
  transform: translateX(3px);
}
}

.copy-btn {
  min-height: 34px;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--paper-2);
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 180ms var(--ease-out), border-color 180ms var(--ease-out), transform 160ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
.copy-btn:hover {
  color: var(--paper);
  border-color: rgba(237, 234, 227, 0.32);
}
}

.copy-btn:active {
  transform: scale(0.95);
}

.copy-btn.copied {
  color: var(--shu-hi);
  border-color: rgba(229, 85, 59, 0.5);
}

/* ---------- Footer ---------- */
.footer {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
  padding: 2.5rem clamp(1.25rem, 3vw, 2.25rem) 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(237, 234, 227, 0.025), rgba(237, 234, 227, 0.005));
}

.footer-heading {
  margin: 0 0 0.6rem;
  color: var(--paper-3);
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.footer-brand-home {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  color: var(--paper);
  text-decoration: none;
}

.footer-brand-home .footer-heading {
  margin: 0;
  color: var(--paper);
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 600;
}

@media (hover: hover) and (pointer: fine) {
.footer-brand-home:hover .footer-heading {
  color: var(--paper);
}
}

.footer-brand-logo {
  width: 40px;
  height: 40px;
}

.footer-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.footer-col a,
.footer-col p {
  color: var(--paper-2);
  font-size: 0.92rem;
}

.footer-col p {
  max-width: 38ch;
  line-height: 1.6;
}

.footer-col a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  text-decoration: none;
  transition: color 180ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
.footer-col a:hover {
  color: var(--paper);
}
}

.footer-bottom {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  margin-top: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--paper-3);
  font-size: 0.82rem;
}

.back-to-top {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: var(--z-float);
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(17, 17, 19, 0.85);
  color: var(--paper);
  backdrop-filter: blur(14px);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out), border-color 180ms var(--ease-out);
}

.back-to-top.visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
.back-to-top:hover {
  border-color: var(--shu);
}
}

/* ---------- Reveal (shared) ----------
   Only panels and cards reveal on scroll, and only by a short fade-rise.
   Headings and body text are never animated on scroll. */
@media (prefers-reduced-motion: no-preference) {
  .js [data-reveal] {
    opacity: 0;
    transform: translateY(8px);
    transition:
      opacity 520ms var(--ease-out),
      transform 520ms var(--ease-out);
    transition-delay: calc(var(--i, 0) * 50ms);
  }

  .js [data-reveal].is-in {
    opacity: 1;
    transform: none;
  }
}

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

  .footer-col:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  nav[aria-label="Primary"] {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    border-radius: 18px;
    padding: 0.5rem 0.5rem 0.5rem 0.75rem;
  }

  .nav-brand {
    justify-content: flex-start;
  }

  .nav-links {
    width: auto;
    justify-content: flex-end;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-links a {
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
  }

  .nav-links a:nth-child(-n+2) {
    display: none;
  }
}

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

/* Touch screens: every control is at least 44px tall. */
@media (pointer: coarse) {
  .copy-btn,
  .ask-replay {
    min-height: 44px;
    padding-inline: 1rem;
  }
}

@media (forced-colors: active) {
  .btn.primary {
    border: 1px solid ButtonText;
  }
}
