/* =======================================================================
   ampere insight — Base styles
   Dark-first design with CSS variables & utilities.
   ======================================================================= */

:root {
  /* Light theme */
  --bg: #f7f8fb;
  --bg-alt: #ffffff;
  --text: #0b0f1a;
  --muted: #54607a;
  --card: #ffffff;
  --border: #e7e9f2;
  --brand: #3b82f6;   /* accent */
  --brand-2: #22d3ee; /* secondary accent */
  --shadow: 0 10px 30px rgba(16, 24, 40, .08);
  --radius: 16px;

  /* Timeline */
  --tl-pad: 56px;
  --tl-line-x: 28px;
  --dot-size: 16px;
  --dot-border: 2px;
}

html[data-theme="dark"] {
  --bg: #0a0f18;
  --bg-alt: #0e1524;
  --text: #e6ebf5;
  --muted: #9aa6bf;
  --card: #10192e;
  --border: #1d2a44;
  --brand: #60a5fa;
  --brand-2: #22d3ee;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --radius: 16px;
}

/* Reset & base */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  color: var(--text);
  background: var(--bg); /* solid base — gradients moved to body::before */
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
/* Paint page gradients on a fixed layer to avoid seams in sections */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -4;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(96,165,250,.08), transparent 60%),
    radial-gradient(1000px 600px at 90% 20%, rgba(34,211,238,.06), transparent 60%),
    var(--bg);
}

img, svg, video { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 1rem; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
.h1 { font-size: clamp(2rem, 3vw + 1rem, 3.2rem); letter-spacing: -0.02em; }
.h2 { font-size: clamp(1.6rem, 1.2vw + 1rem, 2rem); }

/* Containers & Layout */
.container { width: min(1120px, 92%); margin: 0 auto; }

/* Sections
   - Base sections are transparent (show gradients)
   - .alt sections are solid bands (clear separation)
   - isolation avoids weird blending with fixed layers
*/
.section {
  position: relative;
  padding: 5rem 0;
  background: transparent;
  isolation: isolate;
}
.section.alt { background: var(--bg-alt); }

.section-header { margin-bottom: 2rem; }
.section-sub { color: var(--muted); }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-alt) 60%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: .8rem 0; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; color: var(--text); }
.logo { color: var(--brand-2); }
.brand-name { letter-spacing: .2px; }

.nav .nav-list { display: flex; align-items: center; gap: 1rem; list-style: none; padding: 0; margin: 0; }
.nav a { color: var(--text); opacity: .9; }
.nav a:hover { opacity: 1; }

.nav-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: 0; }
.nav-toggle-bar { width: 22px; height: 2px; background: var(--text); display: block; border-radius: 2px; }

.theme-toggle {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: .4rem .6rem; cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-alt); }

@media (max-width: 800px) {
  .nav-toggle { display: inline-flex; }
  .nav .nav-list {
    position: absolute; right: 1rem; top: 64px; background: var(--bg-alt);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: .8rem; display: none; flex-direction: column; gap: .6rem; box-shadow: var(--shadow);
    min-width: 200px;
  }
  .nav .nav-list.is-open { display: flex; }
}

/* Buttons & Chips */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white; border: 0; border-radius: 999px; padding: .8rem 1.1rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 18px rgba(59,130,246,.25);
  transition: transform .15s ease, box-shadow .15s ease, opacity .2s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(59,130,246,.35); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.small { padding: .55rem .8rem; font-size: .9rem; }

.chip {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: .45rem .8rem; cursor: pointer;
}
.chip.is-active, .chip:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }

/* Hero */
.hero { padding-top: 6rem; }
.hero .lead { color: var(--muted); max-width: 60ch; }
.hero-cta { display: flex; gap: .8rem; margin: 1.2rem 0 1.1rem; flex-wrap: wrap; }
.badges { display: flex; gap: .5rem; list-style: none; padding: 0; margin: .4rem 0 1.2rem; flex-wrap: wrap; }
.badge {
  font-size: .85rem; color: var(--brand);
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  border: 1px dashed color-mix(in srgb, var(--brand) 40%, transparent);
  padding: .25rem .6rem; border-radius: 999px;
}

.kpis { display: flex; gap: 1.6rem; margin-top: .8rem; }
.kpi { display: grid; gap: .1rem; }
.kpi-num { font-size: 1.6rem; font-weight: 800; }
.kpi-txt { color: var(--muted); }

.hero-panel .code-card pre {
  margin: 0; padding: 1rem 1.2rem; border-radius: calc(var(--radius) - 2px);
  background: #0c1424; color: #d7e2ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  border: 1px solid #1b2a49; overflow: auto;
}

/* Cards */
.glass.card {
  background: color-mix(in srgb, var(--card) 75%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1.1rem 1.1rem 0.8rem; }
.card-footer, .card-actions { padding: .8rem 1.1rem 1.1rem; display: flex; gap: .6rem; align-items: center; }
.card-title { font-size: 1.1rem; margin-bottom: .2rem; }
.card-text { color: var(--muted); }

/* Cards grid */
.cards .card { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.cards .card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); }
.tags { display: flex; gap: .5rem; list-style: none; padding: 0; margin: .6rem 0 0; }
.tags li { font-size: .8rem; color: var(--muted); border: 1px dashed var(--border); padding: .18rem .5rem; border-radius: 999px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.4rem; }

/* ============================
   Timeline
   ============================ */
.timeline {
  list-style: none;
  margin: 0;
  padding-left: 58px; /* reserve space for line + dots */
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 28px; top: 0; bottom: 0;
  border-left: 2px dotted var(--border);
}
.step { position: relative; padding: .6rem 0 1.1rem 0; }
.step-dot {
  position: absolute;
  left: calc(var(--tl-line-x) - ((var(--dot-size) + 2*var(--dot-border)) / 2) - var(--tl-pad));
  top: .95rem;
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: 2px solid var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
}
.step-body h3 { margin: .1rem 0 .2rem; line-height: 1.2; }
.step-body p { margin: 0; color: var(--muted); }

/* FAQ */
.faq-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); padding: .9rem 1.1rem; margin-bottom: .7rem;
}
.faq-item summary { cursor: pointer; font-weight: 600; }
.faq-item p { color: var(--muted); margin-top: .5rem; }

/* Contact */
.contact-form {
  display: grid; gap: .8rem; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow);
}
.contact-form label { display: grid; gap: .35rem; }
.contact-form input, .contact-form textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: .7rem .9rem; outline: none;
}
.contact-form input:focus, .contact-form textarea:focus {
  border-color: color-mix(in srgb, var(--brand) 40%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 20%, transparent);
}
.form-note { color: var(--muted); font-size: .9rem; }
.contact-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.contact-list a { text-decoration: underline; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 1.2rem 0; background: var(--bg-alt); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.footer-nav a { color: var(--muted); margin-left: 1rem; }
.footer-nav a:hover { color: var(--text); }

/* Utilities */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.to-top {
  position: fixed; right: 1rem; bottom: 1rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-alt); color: var(--text); width: 40px; height: 40px; display: grid; place-items: center;
  box-shadow: var(--shadow); cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.to-top.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* Reveal on scroll */
.in-view { animation: float-in .6s cubic-bezier(.2,.65,.3,1) both; }
@keyframes float-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Background decorative orbs */
.bg-orb {
  position: fixed; width: 480px; height: 480px; border-radius: 50%;
  filter: blur(60px); opacity: .25; pointer-events: none; z-index: -3; /* below sections, above body::before */
  background: radial-gradient(circle at 30% 30%, var(--brand), transparent 60%);
}
.orb-1 { top: -160px; left: -120px; }
.orb-2 {
  bottom: -160px; right: -120px;
  background: radial-gradient(circle at 70% 70%, var(--brand-2), transparent 60%);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Logo swap for themes */
.logo { display:block; height:28px; width:auto; color: unset; }
.logo-light { display:none; }
html[data-theme="light"] .logo-dark { display:none; }
html[data-theme="light"] .logo-light { display:block; }

/* Anchor jumps land below sticky header */
section[id] { scroll-margin-top: 72px; }

/* =======================================================================
   Principles carousel
   - Edge fade via CSS mask (no painted overlay), blends with section bg
   - No scale on active card (prevents text blur / pop)
   ======================================================================= */

.p-wrap { position: relative; margin-top: .6rem; }
.p-view {
  overflow: hidden;
  padding: .4rem 0 1rem;

  /* Edge fade via mask (no background paint) */
  --p-fade: 64px;
  -webkit-mask-image: linear-gradient(to right,
    transparent 0,
    #000 var(--p-fade),
    #000 calc(100% - var(--p-fade)),
    transparent 100%);
          mask-image: linear-gradient(to right,
    transparent 0,
    #000 var(--p-fade),
    #000 calc(100% - var(--p-fade)),
    transparent 100%);
}
.p-track {
  list-style: none; margin: 0; padding: 0;
  display: flex; align-items: stretch; gap: 1.2rem;
  will-change: auto; /* avoid forced compositing (crisper text) */
}
.p-slide { flex: 0 0 auto; }
.p-card {
  width: clamp(260px, 58vw, 520px);
  transform: none;
  opacity: .9;
  transition: opacity .25s ease, box-shadow .25s ease, border-color .25s ease;
}
@media (min-width: 960px) {
  .p-card { width: clamp(360px, 36vw, 520px); }
}
.p-card.is-active {
  transform: none;        /* no scale => crisp text, no pop */
  opacity: 1.0;
  border-color: color-mix(in srgb, var(--brand) 32%, var(--border));
  box-shadow: 0 10px 28px rgba(59,130,246,.14);
}

/* Carousel arrows */
.p-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-alt) 80%, transparent);
  backdrop-filter: blur(4px);
  color: var(--text);
  box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; z-index: 2;
}
.p-nav:hover { background: color-mix(in srgb, var(--bg) 80%, transparent); }
.p-nav:disabled { opacity: .4; cursor: default; }
.p-nav.prev { left: .2rem; }
.p-nav.next { right: .2rem; }


.section.alt2 {
  position: relative;
  isolation: isolate;      /* keep effects contained to this section */
  background: none;        /* draw gradient on ::before layer */
}

.section.alt2::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;             /* sit behind content, above page background */

  /* Soft, brand-tinted corners over the solid alt base */
  background:
    radial-gradient(900px 460px at 12% 8%,
      color-mix(in srgb, var(--brand) 22%, transparent) 0%,
      transparent 70%),
    radial-gradient(820px 420px at 88% 92%,
      color-mix(in srgb, var(--brand-2) 22%, transparent) 0%,
      transparent 72%),
    var(--bg-alt);
  transform: translateZ(0); /* avoids subpixel seams on some GPUs */
}


/* ===== About page: portrait sizing ===== */
.about-portrait {
  display: grid;
  justify-items: center;
  gap: .6rem;
}

.about-portrait .profile-pic {
  /* Scales nicely from mobile to desktop */
  inline-size: clamp(180px, 28vw, 320px);
  block-size: clamp(180px, 28vw, 320px);
  aspect-ratio: 1 / 1;
  object-fit: cover;

  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg-alt);
}

/* Optional: small, muted caption under the photo */
.about-portrait figcaption {
  font-size: .9rem;
  color: var(--muted);
}
/* --- Hero: mobile optimizations --- */
@media (max-width: 768px) {
  .hero { padding-top: 4.25rem; }            /* less headroom under the sticky header */
  .hero .grid-2 { gap: 1.2rem; }             /* tighter column gap on phones */

  .hero .h1 {                                 /* scale headline a touch smaller */
    font-size: clamp(1.65rem, 6.2vw + .5rem, 2.1rem);
  }
  .hero .lead { font-size: 1rem; }

  /* KPIs wrap instead of forcing a wide row */
  .kpis {
    flex-wrap: wrap;
    gap: .8rem 1.2rem;
  }
  .kpi {
    flex: 1 1 calc(50% - 1.2rem);            /* two per row on small screens */
    min-width: 120px;
  }

  /* Code card: ensure it never overflows, and make the monospace text friendlier */
  .hero-panel .code-card { max-width: 100%; }
  .hero-panel .code-card pre {
    font-size: .9rem;
    line-height: 1.4;
    overflow-x: auto;                         /* keep any long lines inside the card */
  }
}

/* Prevent rogue horizontal scrolling in the hero on iOS (fixed layers/orbs) */
#hero { overflow-x: clip; }
/* --- Hero code card: prevent overflow on mobile --- */
.grid-2 > * { min-width: 0; }          /* allow grid children to shrink */
.hero-copy, .hero-panel { min-width: 0; }

.hero-panel .code-card { max-width: 100%; }
.hero-panel .code-card pre {
  max-width: 100%;
  overflow-x: auto;                     /* allow horizontal scroll if needed */
  white-space: pre;                     /* keep code formatting by default */
}

/* On narrow screens, wrap long lines so the card can “squeeze” neatly */
@media (max-width: 560px) {
  .hero-panel .code-card pre {
    white-space: pre-wrap;              /* allow wrapping */
    word-break: break-word;             /* break very long tokens if required */
  }
}
.hp { position: absolute; left: -9999px; opacity: 0; }



/* --- Case gallery (small, matches site look) --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
}
.gallery-item {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-alt);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  transition: transform .2s ease;
  display: block;
}
.gallery-item:hover img { transform: scale(1.04); }
.more-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: color-mix(in srgb, var(--bg) 35%, transparent);
  backdrop-filter: blur(2px);
}

/* --- Lightbox --- */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10,15,24,.9);
  display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; justify-items: center;
  opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.lightbox[aria-hidden="false"] { opacity: 1; pointer-events: auto; }
.lb-figure { max-width: min(1100px, 92vw); max-height: 88vh; margin: 0; display: grid; gap: .6rem; justify-items: center; }
.lb-figure img {
  max-width: 100%; max-height: 80vh;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-alt); box-shadow: var(--shadow);
}
.lb-figure figcaption { color: var(--muted); font-size: .95rem; text-align: center; }
.lb-btn {
  width: 44px; height: 44px; border-radius: 999px;
  border: 1px solid var(--border); background: color-mix(in srgb, var(--bg-alt) 85%, transparent);
  color: var(--text); box-shadow: var(--shadow); cursor: pointer;
}
.lb-close { position: absolute; top: 1rem; right: 1rem; }
@media (max-width: 960px){ .lightbox { grid-template-columns: 44px 1fr 44px; } }


/* --- Section flow arrows --- */
#case-sections .flow-card {
  position: relative;
  margin-bottom: 2.4rem; /* room for the arrow connector */
}

/* vertical connector line */
#case-sections .flow-card:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  width: 2px;
  height: 16px;
  background: var(--border);
  opacity: 0.9;
}

/* arrow head */
#case-sections .flow-card:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -30px;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
  background: transparent;
  opacity: 0.9;
}

/* keep it crisp on hover/focus too */
#case-sections .flow-card:hover::after,
#case-sections .flow-card:hover::before {
  opacity: 1;
}
