/* Karamatics components, v1: buttons, navigation, theme toggle, hero backdrop, quotations, chips and footer.
 * Requires tokens.css and base.css. Page-specific layout (grid columns, headline sizes) stays with the page. */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 50px; padding: 0 26px; border-radius: 12px;
  font: 500 .98rem var(--font-sans); letter-spacing: .005em;
  text-decoration: none; border: 1px solid transparent; cursor: pointer;
  transition: background-position .5s ease, transform .25s ease, box-shadow .3s ease, border-color .25s ease, background-color .25s ease, color .25s ease;
}
.btn-primary {
  color: var(--on-brand);
  background-image: linear-gradient(100deg, var(--brand-purple) 0%, var(--brand-violet) 45%, var(--brand-blue) 100%);
  background-size: 220% 100%; background-position: 0 0;
  box-shadow: 0 10px 28px -12px rgba(124, 58, 237, .8), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.btn-primary:hover {
  background-position: 100% 0; transform: translateY(-2px);
  box-shadow: 0 16px 36px -12px rgba(37, 99, 235, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:active { transform: translateY(0); }
.btn-ghost { color: var(--ink); border-color: var(--line-strong); background: transparent; }
.btn-ghost:hover { border-color: var(--purple); background: var(--tint); color: var(--accent-text); transform: translateY(-2px); }
.btn-ghost:active { transform: translateY(0); }
/* For use on dark brand panels */
.btn-light { background: var(--on-brand); color: #1E1B4B; box-shadow: 0 12px 30px -14px rgba(0, 0, 0, .6); }
.btn-light:hover { background: #EDE9FE; transform: translateY(-2px); box-shadow: 0 18px 40px -14px rgba(167, 139, 250, .7); }
.btn-sm { height: 40px; padding: 0 18px; border-radius: 10px; font-size: .92rem; }

/* ---------- Navigation ---------- */
.nav {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid transparent; transition: border-color .3s;
}
/* fills the iOS safe area above the sticky bar */
.nav::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%;
  height: env(safe-area-inset-top, 0px); background: var(--nav-bg);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-size: 1.45rem; font-weight: 500; letter-spacing: -.01em; }
.brand svg { width: 30px; height: 30px; }
.nav-links { display: flex; gap: 34px; }
.nav-links a { position: relative; text-decoration: none; color: var(--ink-2); font-size: .95rem; padding: 6px 0; transition: color .2s; }
.nav-links a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--purple); transform: scaleX(0); transform-origin: left; transition: transform .3s ease; }
.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::after { transform: scaleX(1); }
.nav-actions { display: flex; align-items: center; gap: 14px; }
@media (max-width: 760px) { .nav-links { display: none; } }

/* ---------- Theme toggle (behavior in theme.js) ---------- */
.toggle {
  position: relative; width: 58px; height: 32px; padding: 0; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--bg-soft); cursor: pointer;
  transition: border-color .3s, background-color .4s;
}
.toggle:hover { border-color: var(--purple); }
.toggle-knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-gradient);
  box-shadow: 0 3px 10px -3px rgba(124, 58, 237, .7);
  transition: transform .55s cubic-bezier(.6, -.35, .3, 1.35);
}
.toggle[aria-checked="true"] .toggle-knob { transform: translateX(26px); }
.toggle svg { grid-area: 1 / 1; width: 14px; height: 14px; fill: none; stroke: var(--on-brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: opacity .3s ease, transform .55s ease; }
.toggle .i-moon { opacity: 0; transform: rotate(-70deg) scale(.4); }
.toggle[aria-checked="true"] .i-sun { opacity: 0; transform: rotate(90deg) scale(.4); }
.toggle[aria-checked="true"] .i-moon { opacity: 1; transform: none; }

/* ---------- Hero backdrop and intro text ---------- */
.hero { position: relative; isolation: isolate; overflow: clip; padding: clamp(40px, 7vw, 96px) 0 clamp(56px, 8vw, 112px); }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2; pointer-events: none;
  background-image: radial-gradient(var(--dot) 1px, transparent 1.5px); background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 68% 40%, #000 15%, transparent 75%);
  mask-image: radial-gradient(ellipse 85% 75% at 68% 40%, #000 15%, transparent 75%);
}
.hero::after {
  content: ""; position: absolute; z-index: -1; pointer-events: none;
  width: 900px; height: 900px; right: -280px; top: -380px;
  background: radial-gradient(closest-side, var(--glow), transparent);
}

.eyebrow { display: inline-flex; align-items: center; gap: 14px; margin: 0 0 26px; font: 500 .8rem var(--font-mono); letter-spacing: .22em; color: var(--accent-text); }
.eyebrow::before { content: ""; width: 30px; height: 1px; background: var(--purple); }
.lead { font-size: clamp(1.08rem, 1.5vw, 1.25rem); line-height: 1.6; color: var(--ink-2); max-width: 34em; margin-bottom: 36px; }
.cta-row { display: flex; flex-wrap: wrap; gap: 14px; }

/* Drifting math symbols behind a hero; position each span inline with top/left/right/bottom, --d (duration) and --o (opacity) */
.glyphs { position: absolute; inset: 0; z-index: -1; pointer-events: none; user-select: none; }
.glyphs span {
  position: absolute; font-family: var(--font-display); font-style: italic; line-height: 1;
  color: var(--purple); opacity: var(--o, .14);
  animation: drift var(--d, 26s) ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translate(0, 0) rotate(0deg); } to { transform: translate(10px, -16px) rotate(3deg); } }

/* Caption row under a figure: formula on one side, controls on the other */
.fig-cap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px; font: .82rem var(--font-mono); color: var(--muted); }
.fig-cap .formula { color: var(--ink-2); }

/* ---------- Quotations ---------- */
.quote { position: relative; overflow: clip; padding: clamp(56px, 8vw, 104px) 0; background: var(--bg-soft); border-block: 1px solid var(--line); }
.quote figure { position: relative; max-width: 880px; margin: 0 auto; text-align: center; }
.quote--left figure { max-width: none; margin: 0; text-align: left; }
.quote--left blockquote { max-width: 24em; }
.q-glyph { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font: italic 400 clamp(12rem, 30vw, 22rem)/1 var(--font-display); color: var(--purple); opacity: .07; pointer-events: none; user-select: none; }
.quote--left .q-glyph { left: auto; right: 4%; transform: translateY(-50%); }
blockquote { margin: 0; position: relative; }
blockquote p { font-family: var(--font-display); font-style: italic; font-size: clamp(1.7rem, 3.6vw, 2.75rem); line-height: 1.25; letter-spacing: -.01em; text-wrap: balance; }
blockquote p::before { content: "\201C"; }
blockquote p::after { content: "\201D"; }
.quote figcaption { position: relative; margin-top: 24px; font: .85rem var(--font-mono); color: var(--muted); }
.quote figcaption strong { color: var(--ink); font-weight: 500; }

/* ---------- Chips and status pill ---------- */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { padding: 4px 13px; font-size: .88rem; color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 999px; }
.status { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 18px; padding: 4px 13px; font: 500 .8rem var(--font-mono); color: var(--accent-text); background: var(--tint); border: 1px solid var(--line); border-radius: 999px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--purple); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 22px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.field { display: grid; gap: 8px; align-content: start; }
.field > label { font-size: .92rem; font-weight: 500; color: var(--ink); }
.field .optional { margin-left: 6px; font: 400 .78rem var(--font-mono); color: var(--muted); }
.input {
  width: 100%; min-height: 50px; padding: 12px 16px;
  font: 400 1rem/1.5 var(--font-sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--muted); opacity: .75; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px var(--tint); }
textarea.input { min-height: 168px; resize: vertical; }
select.input {
  -webkit-appearance: none; appearance: none; padding-right: 44px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 52%, calc(100% - 16px) 52%; background-size: 6px 6px; background-repeat: no-repeat;
}
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent); }
.field-error { font-size: .86rem; color: var(--danger); }
.field-hint { font-size: .86rem; color: var(--muted); }
.form-status { padding: 14px 16px; border: 1px solid; border-radius: 12px; font-size: .95rem; }
.form-status--error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.form-status--success { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: color-mix(in srgb, var(--success) 7%, transparent); }
.form-status a { color: inherit; font-weight: 500; }
.btn:disabled { opacity: .65; cursor: progress; transform: none; }
/* Spam trap: hidden from people and assistive tech, still filled in by naive bots */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Footer ---------- */
.footer { padding: 40px 0; }
.foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; }
.foot-brand { display: grid; gap: 4px; }
.foot-brand p { font-size: .9rem; color: var(--muted); }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.foot nav a { color: var(--muted); text-decoration: none; font-size: .95rem; transition: color .2s; }
.foot nav a:hover { color: var(--ink); }
.copy { font: .8rem var(--font-mono); color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .glyphs span { animation: none; }
  .btn, .toggle-knob, .toggle svg, .input { transition: none; }
}
