/* Self-hosted fonts (latin subset). Fraunces is the same variable font (opsz + wght, upright and italic) the page used from Google Fonts; Manrope is the guide's file. */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url("assets/fonts/fraunces-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces"; font-style: italic; font-weight: 300 700; font-display: swap;
  src: url("assets/fonts/fraunces-latin-italic.woff2") format("woff2");
}
@font-face {
  font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url("assets/fonts/manrope-latin.woff2") format("woff2");
}

/* Tidya Design Language: dark is the default, light follows the OS
   unless the visitor has picked a theme (data-theme on <html>) */
:root {
  --color-bg: #1a1816;
  --color-surface: #272422;
  --color-text: #ffffff;
  --color-text-secondary: #d4a88f;
  --color-text-muted: rgba(255, 255, 255, 0.50);
  --color-accent: #ffbe0b;
  --color-accent-hover: #ffc933;
  /* button fill: stays vivid in both themes (--color-accent darkens for text in light) */
  --color-accent-fill: #ffbe0b;
  --color-accent-fill-hover: #ffc933;
  --color-accent-fill-edge: transparent;
  --color-label: #e0956d;
  --color-link: #d4a88f;
  --color-border: rgba(255, 255, 255, 0.06);
  --color-border-subtle: rgba(255, 255, 255, 0.10);
  --color-border-medium: rgba(255, 255, 255, 0.15);
  --color-accent-border: rgba(255, 190, 11, 0.35);
  --color-accent-border-dashed: rgba(255, 190, 11, 0.40);
  --color-accent-bg-subtle: rgba(255, 190, 11, 0.05);

  /* page extensions to the guide: AA-safe text on/with the accent, rgb triples for alpha mixes */
  --color-on-accent: #1a1816;
  --color-accent-text: #ffbe0b;
  --color-bg-rgb: 26, 24, 22;
  --color-text-rgb: 255, 255, 255;
  --color-accent-rgb: 255, 190, 11;

  /* from tidya-design-guide: form, dialog and alert tokens (text sizes: base is 1rem so iOS does not zoom into inputs) */
  --color-error: #ff5c5c;
  --color-error-bg: rgba(255, 82, 82, 0.12);
  --color-success: #4cc38a;
  --color-success-bg: rgba(76, 195, 138, 0.12);
  --color-border-control: rgba(255, 255, 255, 0.34);
  --color-focus-halo: rgba(255, 190, 11, 0.18);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
  --color-overlay: rgba(0, 0, 0, 0.60);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --text-xs: 0.8125rem; --text-sm: 0.875rem; --text-base: 1rem; --text-lg: 1.125rem;

  --shader-sky-top: 0.20, 0.13, 0.07;
  --shader-sky-bottom: 0.102, 0.094, 0.086;
  --shader-cloud: 0.36, 0.24, 0.09;
  --shader-shadow: 0.24, 0.12, 0.06;
  --shader-opacity: 0.9;
  --logo-filter: grayscale(1) brightness(1.15);
  --logo-filter-hover: grayscale(1) brightness(1.3);
  --theme-icon-sun: 1; /* the toggle shows the mode it switches to */

  --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 10px;
  --t-fast: 0.15s ease;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --color-bg: #f7f3ee;
    --color-surface: #ede8e1;
    --color-text: #1a1816;
    --color-text-secondary: #7a4a2e;
    --color-text-muted: rgba(26, 24, 22, 0.50);
    --color-accent: #c48a00;
    --color-accent-hover: #a87500;
    --color-accent-fill: #ffbe0b;
    --color-accent-fill-hover: #f0a800;
    --color-accent-fill-edge: rgba(138, 93, 0, 0.35);
    --color-label: #9c3d1a;
    --color-link: #7a4a2e;
    --color-border: rgba(26, 24, 22, 0.07);
    --color-border-subtle: rgba(26, 24, 22, 0.12);
    --color-border-medium: rgba(26, 24, 22, 0.20);
    --color-accent-border: rgba(180, 120, 0, 0.45);
    --color-accent-border-dashed: rgba(180, 120, 0, 0.50);
    --color-accent-bg-subtle: rgba(255, 190, 11, 0.10);

    --color-accent-text: #8a6100;
    --color-bg-rgb: 247, 243, 238;
    --color-text-rgb: 26, 24, 22;
    --color-accent-rgb: 196, 138, 0;

    --color-error: #c82020;
    --color-error-bg: rgba(200, 32, 32, 0.08);
    --color-success: #1e7a4f;
    --color-success-bg: rgba(30, 122, 79, 0.10);
    --color-border-control: rgba(28, 23, 18, 0.49);
    --color-focus-halo: rgba(255, 190, 11, 0.45);
    --shadow-lg: 0 12px 32px rgba(28, 23, 18, 0.16);
    --color-overlay: rgba(28, 23, 18, 0.45);

    --shader-sky-top: 1.0, 0.86, 0.58;
    --shader-sky-bottom: 0.969, 0.953, 0.933;
    --shader-cloud: 1.0, 0.98, 0.94;
    --shader-shadow: 0.96, 0.78, 0.48;
    --shader-opacity: 1;
    --logo-filter: invert(0.82) grayscale(1);
    --logo-filter-hover: invert(0.95) grayscale(1);
    --theme-icon-sun: 0;

    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --color-bg: #f7f3ee;
  --color-surface: #ede8e1;
  --color-text: #1a1816;
  --color-text-secondary: #7a4a2e;
  --color-text-muted: rgba(26, 24, 22, 0.50);
  --color-accent: #c48a00;
  --color-accent-hover: #a87500;
  --color-accent-fill: #ffbe0b;
  --color-accent-fill-hover: #f0a800;
  --color-accent-fill-edge: rgba(138, 93, 0, 0.35);
  --color-label: #9c3d1a;
  --color-link: #7a4a2e;
  --color-border: rgba(26, 24, 22, 0.07);
  --color-border-subtle: rgba(26, 24, 22, 0.12);
  --color-border-medium: rgba(26, 24, 22, 0.20);
  --color-accent-border: rgba(180, 120, 0, 0.45);
  --color-accent-border-dashed: rgba(180, 120, 0, 0.50);
  --color-accent-bg-subtle: rgba(255, 190, 11, 0.10);

  --color-accent-text: #8a6100;
  --color-bg-rgb: 247, 243, 238;
  --color-text-rgb: 26, 24, 22;
  --color-accent-rgb: 196, 138, 0;

  --color-error: #c82020;
  --color-error-bg: rgba(200, 32, 32, 0.08);
  --color-success: #1e7a4f;
  --color-success-bg: rgba(30, 122, 79, 0.10);
  --color-border-control: rgba(28, 23, 18, 0.49);
  --color-focus-halo: rgba(255, 190, 11, 0.45);
  --shadow-lg: 0 12px 32px rgba(28, 23, 18, 0.16);
  --color-overlay: rgba(28, 23, 18, 0.45);

  --shader-sky-top: 1.0, 0.86, 0.58;
  --shader-sky-bottom: 0.969, 0.953, 0.933;
  --shader-cloud: 1.0, 0.98, 0.94;
  --shader-shadow: 0.96, 0.78, 0.48;
  --shader-opacity: 1;
  --logo-filter: invert(0.82) grayscale(1);
  --logo-filter-hover: invert(0.95) grayscale(1);
  --theme-icon-sun: 0;

  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; background: var(--color-bg); }

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.4s var(--ease-out), color 0.4s var(--ease-out);
}
::selection { background: rgba(var(--color-accent-rgb), 0.18); }

.wrap { width: min(1160px, 100% - 2.5rem); margin-inline: auto; }

/* ---------- grain overlay ---------- */
/* A real element, not body::after: iOS 26 Safari tints the status bar from the fixed element it
   hit-tests at the top edge, a pseudo-element counts as <body>, and it skips only real elements
   that are nearly transparent (opacity under 0.1) and pointer-events: none */
.grain {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 999;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- header ---------- */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  transition: background 0.4s, box-shadow 0.4s, backdrop-filter 0.4s;
}
header.scrolled {
  background: rgba(var(--color-bg-rgb), 0.8);
  backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 var(--color-border-subtle);
}
/* iOS 26 Safari colours the strip under the status bar from a fixed header's background,
   but only an opaque one; through a translucent header the scrolled text showed there */
@supports (-webkit-touch-callout: none) {
  header.scrolled { background: var(--color-bg); backdrop-filter: none; }
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 0;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; color: var(--color-text); }
.brand-logo { height: 2.1rem; width: auto; display: block; transition: transform 0.3s var(--ease-out); }
.brand:hover .brand-logo { transform: translateY(-2px); }
.nav-right { display: flex; align-items: center; }
.nav-links { display: flex; align-items: center; gap: 1.8rem; }
.nav-links a {
  color: var(--color-text-secondary); text-decoration: none; font-weight: 500; font-size: 0.95rem;
  position: relative; transition: color 0.25s;
}
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: -5px; height: 2px; width: 100%;
  background: var(--color-accent); border-radius: 2px;
  transform: scaleX(0); transform-origin: right; transition: transform 0.35s var(--ease-out);
}
.nav-links a:hover { color: var(--color-text); }
.nav-links a:hover::after { transform: scaleX(1); transform-origin: left; }

.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 2.4rem; height: 2.4rem; background: none; border: none;
  border-radius: var(--r-lg); color: var(--color-text); cursor: pointer;
  transition: background var(--t-fast);
}
.nav-toggle:hover { background: rgba(var(--color-text-rgb), 0.06); }
.nav-toggle .icon-close { display: none; }
.nav-toggle[aria-expanded="true"] .icon-menu { display: none; }
.nav-toggle[aria-expanded="true"] .icon-close { display: block; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
  width: 2.4rem; height: 2.4rem; background: none; border: 1px solid var(--color-border-subtle);
  border-radius: 999px; color: var(--color-text); cursor: pointer; margin-left: 0.6rem;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.theme-toggle:hover { background: var(--color-accent-bg-subtle); border-color: var(--color-accent-border); }
.theme-toggle svg {
  --on: 1;
  position: absolute; top: 50%; left: 50%;
  opacity: var(--on);
  transform: translate(-50%, -50%) rotate(calc((1 - var(--on)) * 70deg)) scale(calc(0.4 + 0.6 * var(--on)));
  transition: transform 0.45s var(--ease-out), opacity 0.35s var(--ease-out);
}
.theme-toggle .icon-sun { --on: var(--theme-icon-sun); }
.theme-toggle .icon-moon { --on: calc(1 - var(--theme-icon-sun)); }

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; margin-left: 0.5rem; }
  .nav-links {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--color-bg); border-top: 1px solid var(--color-border-subtle);
    box-shadow: 0 16px 30px -18px rgba(var(--color-text-rgb), 0.25);
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--color-border-subtle);
  }
  .nav-links a::after { display: none; }
}


h1 {
  font-family: var(--font-display);
  font-weight: 460;
  font-size: clamp(2.5rem, 5.4vw, 4.5rem);
  line-height: 1.04; letter-spacing: -0.025em;
  max-width: 14ch;
}

.hero-sub {
  margin-top: 1.2rem; font-size: clamp(1.02rem, 1.5vw, 1.22rem);
  color: var(--color-text-secondary); max-width: 42ch;
}

.btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-weight: 600; font-size: 1rem; text-decoration: none;
  padding: 0.95rem 1.5rem; border-radius: var(--r-md); letter-spacing: 0.01em;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform 0.1s ease;
  will-change: transform;
}
.btn-primary { background: var(--color-accent-fill); color: var(--color-on-accent); box-shadow: inset 0 0 0 1px var(--color-accent-fill-edge); }
.btn-primary:hover { background: var(--color-accent-fill-hover); }
.btn-primary .arrow { transition: transform 0.3s var(--ease-out); }
.btn-primary:hover .arrow { transform: translateX(4px); }
.btn-ghost {
  background: rgba(var(--color-bg-rgb), 0.55); color: var(--color-accent-text);
  border: 1px solid var(--color-accent-border); backdrop-filter: blur(6px);
}
.btn-ghost:hover { background: var(--color-accent-bg-subtle); border-color: var(--color-accent-border-dashed); transform: translateY(-1px); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* staggered hero reveal */
.reveal-up { opacity: 0; transform: translateY(28px); animation: rise 0.9s var(--ease-out) forwards; }
.d1 { animation-delay: 0.1s; } .d2 { animation-delay: 0.25s; }
.d3 { animation-delay: 0.4s; } .d4 { animation-delay: 0.55s; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- sections ---------- */
section { position: relative; }
.section-pad { padding: 5.5rem 0; }
@media (max-width: 720px) { .section-pad { padding: 4rem 0; } }
.kicker {
  font-size: 0.82rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--color-label); margin-bottom: 1rem;
}
h2 {
  font-family: var(--font-display); font-weight: 480;
  font-size: clamp(2rem, 4.4vw, 3.2rem); line-height: 1.1; letter-spacing: -0.02em;
  max-width: 22ch;
}
.section-intro { margin-top: 1.1rem; color: var(--color-text-secondary); max-width: 56ch; font-size: 1.08rem; }

/* scroll reveal */
.fade { opacity: 0; transform: translateY(34px); transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out); }
.fade.in { opacity: 1; transform: none; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--color-border-subtle); padding: 3rem 0 3.5rem; color: var(--color-text-secondary); font-size: 0.92rem; }
.footer-grid { display: flex; flex-wrap: wrap; gap: 2rem; justify-content: space-between; align-items: flex-end; }
.footer-grid strong { color: var(--color-text); font-weight: 600; }
footer a { color: var(--color-link); font-weight: 600; text-decoration: none; }
footer a:hover { text-decoration: underline; }
.footer-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1rem; }
.eco-logo { display: block; transition: opacity var(--t-fast); }
.eco-logo:hover { opacity: 0.8; }
.eco-logo img { display: block; height: 50px; width: auto; border-radius: var(--r-sm); }
@media (max-width: 720px) { .footer-right { align-items: flex-start; } .eco-logo img { height: 60px; } }

/* ---------- form, dialog and alert (tidya-design-guide) ---------- */
button.btn { font-family: inherit; cursor: pointer; }
button.btn-primary { border: none; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-ghost:focus-visible { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-focus-halo); }

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.label { font-size: var(--text-sm); font-weight: 600; }
.note { font-size: var(--text-sm); color: var(--color-text-muted); }
.field-error { font-size: var(--text-xs); color: var(--color-error); }
.input, .textarea {
  width: 100%; padding: 0.5rem 0.75rem; font-size: var(--text-base); font-family: inherit;
  background: var(--color-bg); color: var(--color-text);
  border: 1px solid var(--color-border-control); border-radius: var(--r-lg);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.textarea { min-height: 7rem; resize: vertical; }
.input:focus-visible, .textarea:focus-visible { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-focus-halo); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--color-error); }
.input[aria-invalid="true"]:focus-visible, .textarea[aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-error) 28%, transparent); }

.alert {
  --alert-color: var(--color-error); --alert-bg: var(--color-error-bg);
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--r-lg);
  background: var(--alert-bg); border: 1px solid var(--alert-color);
}
.alert.success { --alert-color: var(--color-success); --alert-bg: var(--color-success-bg); }
.alert-icon {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--alert-color); color: var(--color-bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; line-height: 1;
}
.alert-title { font-weight: 600; }
.alert-body { color: var(--color-text-secondary); font-size: var(--text-sm); }

.dialog {
  margin: auto; padding: var(--space-5); width: min(420px, calc(100% - 2 * var(--space-4)));
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border-subtle); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: var(--color-overlay); }
.dialog-title { font-family: var(--font-body); font-size: var(--text-lg); font-weight: 600; letter-spacing: 0; line-height: 1.4; margin-bottom: var(--space-2); }
.dialog-body { color: var(--color-text-secondary); }
.dialog-body + .stack, .dialog-title + .stack { margin-top: var(--space-4); }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
.stack > .dialog-actions { margin-top: var(--space-2); }

.spinner {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: spin 0.7s linear infinite;
}
/* the spinner only takes room while a request runs */
.btn .htmx-indicator { display: none; }
.htmx-request .btn .htmx-indicator { display: inline-flex; }
@keyframes spin { to { transform: rotate(360deg); } }

/* honeypot: out of sight and out of the tab order, but present for bots */
.honning { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
  html { scroll-behavior: auto; }
  .fade { opacity: 1; transform: none; }
  .reveal-up { opacity: 1; transform: none; }
}
