/* ==========================================================================
   Premium layer (opt-in). Loaded only when a landing's site.config.json has
   "premium": true: the build then adds `data-premium` to <body> and expands the
   <!-- build:premium --> marker into this stylesheet + premium.js.
   Every rule is scoped by [data-premium], so without the flag nothing changes.

   Principles: calm, precise, uncluttered. Motion is transform + opacity only and
   is progressive enhancement: content is visible without JavaScript and under
   prefers-reduced-motion. Landing-specific tuning goes in that landing's theme.css
   (under [data-premium]); this file only reads tokens.
   Depends on tokens.css, base.css, landing.css. Load it before theme.css.
   ========================================================================== */

[data-premium] {
  /* ---- Spacing: 8px base. Steps are multiples of 8 at their maximum and ease in fluidly. ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: clamp(1rem, 0.9rem + 0.5vw, 1.5rem);
  --space-5: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --space-6: clamp(2rem, 1.6rem + 2vw, 3rem);
  --space-7: clamp(3rem, 2.4rem + 3vw, 4rem);
  --space-8: clamp(4rem, 3rem + 5vw, 6rem);
  --space-9: clamp(5rem, 3.5rem + 7.5vw, 9rem);

  /* ---- Type ---- */
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --measure: 66ch;

  /* ---- Surfaces and depth ---- */
  --hairline: 1px solid var(--color-border);
  --shadow-sm: 0 1px 1px rgb(17 17 17 / 0.04), 0 2px 4px rgb(17 17 17 / 0.04);
  --shadow-md: 0 1px 1px rgb(17 17 17 / 0.04), 0 4px 8px -2px rgb(17 17 17 / 0.06), 0 14px 28px -10px rgb(17 17 17 / 0.14);
  /* Fine film grain for dark sections: a 160px SVG noise tile inlined as a data URI (no request). */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.07'/%3E%3C/svg%3E");

  /* ---- Motion ---- */
  --reveal-distance: 16px;
  --reveal-duration: 700ms;

  /* ---- Details ---- */
  --selection-bg: var(--color-text);
  --selection-text: var(--color-bg);

  font-kerning: normal;
  font-feature-settings: "kern", "liga", "calt";
  hanging-punctuation: first;
}

:root:has([data-premium]) {
  scroll-padding-top: 5.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) var(--color-bg);
}

[data-premium] ::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

/* ---- Typography ---- */
[data-premium] :is(h1, h2, h3) {
  text-wrap: balance;
}
[data-premium] h1 { letter-spacing: -0.02em; }
[data-premium] h2 { letter-spacing: -0.015em; }
[data-premium] :is(main p, .lead) {
  max-width: var(--measure);
  text-wrap: pretty;
}
[data-premium] .eyebrow {
  font-variant-numeric: tabular-nums;
}

/* ---- Header: a soft blurred backdrop and a hairline appear once the page scrolls ---- */
[data-premium] .site-header {
  background: transparent;
  border-bottom-color: transparent;
}
[data-premium] .site-header::before,
[data-premium] .site-header::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-bottom: var(--border-width) solid var(--header-border);
  pointer-events: none;
  transition: opacity var(--duration) var(--ease);
}
[data-premium] .site-header::before {
  background: var(--header-bg);
}
[data-premium] .site-header::after {
  background: color-mix(in srgb, var(--header-bg) 80%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  box-shadow: var(--shadow-sm);
  opacity: 0;
}
[data-premium] .site-header.is-scrolled::before { opacity: 0; }
[data-premium] .site-header.is-scrolled::after { opacity: 1; }

/* Links: an underline that draws in from the left */
[data-premium] .site-nav a:not(.button) {
  position: relative;
}
@media (min-width: 52rem) {
  [data-premium] .site-nav a:not(.button)::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.5rem;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--duration) var(--ease);
  }
  [data-premium] .site-nav a:not(.button):is(:hover, :focus-visible)::after {
    transform: scaleX(1);
  }
}

/* ---- Buttons ---- */
[data-premium] .button {
  position: relative;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease),
    border-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}
/* The soft layered shadow fades in via opacity (transform/opacity-only motion). */
[data-premium] .button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease);
}
@media (hover: hover) {
  [data-premium] .button:hover {
    transform: translateY(-1px);
  }
  [data-premium] .button:hover::before {
    opacity: 1;
  }
}
[data-premium] .button:active {
  transform: translateY(0);
}
[data-premium] .button:focus-visible {
  outline-offset: 4px;
}
[data-premium] .button[disabled] {
  transform: none;
}

/* ---- Links in running text and footer ---- */
[data-premium] .site-footer a {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 0.3em;
  transition: text-decoration-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
[data-premium] .site-footer a:is(:hover, :focus-visible) {
  text-decoration-color: currentColor;
}

/* ---- Surfaces ---- */
[data-premium] .section--dark {
  background-image: var(--grain);
  background-size: 160px 160px;
}
[data-premium] .section--rule {
  border-top: var(--hairline);
}
[data-premium] .site-footer {
  border-top: var(--hairline);
}

/* ---- Images: tonal finish and gentle settle ---- */
[data-premium] .ph::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* hairline edge + a whisper of warm tone so the whole set reads as one series */
  box-shadow: inset 0 0 0 1px rgb(17 17 17 / 0.06);
  background: linear-gradient(to bottom, transparent 55%, rgb(17 17 17 / 0.06));
}
[data-premium] .ph img {
  transform-origin: 50% 60%;
  transition: transform 1400ms var(--ease);
}
@media (hover: hover) {
  [data-premium] .project:hover .ph img {
    transform: scale(1.02);
  }
}

/* ---- Form: aligned labels, calm fields, clear errors ---- */
[data-premium] .field label {
  line-height: 1.2;
}
[data-premium] .field :is(input, textarea) {
  transition: border-color var(--duration) var(--ease);
}
[data-premium] .field :is(input, textarea):hover {
  border-color: var(--color-text);
}
[data-premium] .field :is(input, textarea):focus-visible {
  outline-offset: 4px;
  box-shadow: 0 1px 0 0 var(--color-text);
}
[data-premium] .field [aria-invalid="true"] {
  box-shadow: 0 1px 0 0 var(--feedback-error);
}
[data-premium] .field__error {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  font-size: var(--text-xs);
  line-height: 1.4;
}
[data-premium] .field__error:empty {
  display: none;
}
[data-premium] .field__error::before {
  content: "";
  flex: none;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-0.1em);
}
[data-premium] .form-status[data-state] {
  background: color-mix(in srgb, currentColor 6%, transparent);
}
/* Turnstile: reserve its space and set it on a quiet hairline panel so nothing shifts when it loads. */
[data-premium] .cf-turnstile {
  display: flex;
  align-items: center;
  min-height: calc(65px + 2 * var(--space-3));
  padding: var(--space-3);
  border: var(--hairline);
  background: color-mix(in srgb, var(--color-bg) 60%, transparent);
  overflow: hidden;
}

/* ---- Scroll reveal (premium.js adds [data-reveal], .is-in and html.reveal-ready) ----
   Elements are only hidden once the script has run and observed them, so without
   JavaScript, or under prefers-reduced-motion, everything stays visible. */
[data-premium] [data-reveal] {
  transition: opacity var(--reveal-duration) var(--ease), transform var(--reveal-duration) var(--ease);
}
.reveal-ready [data-reveal]:not(.is-in) {
  opacity: 0;
  transform: translateY(var(--reveal-distance));
}
.reveal-ready [data-reveal]:not(.is-in) .ph img {
  transform: scale(1.045);
}

/* Hero image: settles in with a barely-there scale (no opacity change, so LCP is unaffected). */
@media (prefers-reduced-motion: no-preference) {
  [data-premium] .hero .ph img {
    animation: premium-settle 1400ms var(--ease) both;
  }
}
@keyframes premium-settle {
  from { transform: scale(1.035); }
  to { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  [data-premium] *,
  [data-premium] *::before,
  [data-premium] *::after {
    animation: none !important;
    transition: none !important;
  }
  [data-premium] [data-reveal],
  [data-premium] [data-reveal] .ph img,
  [data-premium] .button:hover,
  [data-premium] .project:hover .ph img {
    opacity: 1 !important;
    transform: none !important;
  }
}

@media print {
  [data-premium] [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
}
