/* ==========================================================================
   Alanne Sagun — Portfolio
   Minimal, professional, quietly interactive.
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --bg-alt: #f2f0ea;
  --surface: #ffffff;
  --border: #e4e1d8;
  --text: #17181a;
  --text-dim: #57595e;
  --text-mute: #86888d;
  --accent: #1e5654;
  --accent-2: #2c6e6a;
  --accent-soft: #e4efee;
  --focus: #2c6e6a;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 8px 24px rgba(20, 20, 20, 0.06);
  --radius: 14px;
  --radius-sm: 8px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101214;
  --bg-alt: #16191c;
  --surface: #1a1d20;
  --border: #2a2e32;
  --text: #f2f2f0;
  --text-dim: #b6bac0;
  --text-mute: #82868c;
  --accent: #6fd6c9;
  --accent-2: #8fe6d9;
  --accent-soft: #16302d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101214;
    --bg-alt: #16191c;
    --surface: #1a1d20;
    --border: #2a2e32;
    --text: #f2f2f0;
    --text-dim: #b6bac0;
    --text-mute: #82868c;
    --accent: #6fd6c9;
    --accent-2: #8fe6d9;
    --accent-soft: #16302d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

h1, h2, h3 { font-weight: 700; line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
a { color: inherit; }
.muted { color: var(--text-mute); }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff;
  padding: 10px 16px; z-index: 200; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; gap: 16px; }
.brand { font-weight: 800; font-size: 1.05rem; text-decoration: none; }
.brand span { color: var(--accent); }

.nav { display: flex; align-items: center; gap: 24px; }
.nav a { text-decoration: none; font-size: 0.92rem; font-weight: 500; color: var(--text-dim); position: relative; padding: 4px 0; }
.nav a:hover, .nav a.active { color: var(--text); }
.nav a.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px; background: var(--accent); border-radius: 2px;
}
.nav-cta {
  background: var(--accent); color: #fff !important; padding: 8px 16px !important; border-radius: 999px;
}
.nav-cta:hover { background: var(--accent-2); }
.nav-cta.active::after { display: none; }

.theme-toggle {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center; transition: transform 0.2s ease;
}
.theme-toggle:hover { transform: rotate(20deg); }

.nav-burger { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-burger span { width: 22px; height: 2px; background: var(--text); display: block; }

/* ------------------------------------------------------------------ hero */

.hero { padding: 96px 0 72px; }
.eyebrow { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; color: var(--accent-2); font-weight: 600; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4rem); }
.hero-lede { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--text-dim); max-width: 640px; }
.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; margin: 28px 0 48px; }

.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin: 0; padding: 28px 0 0; border-top: 1px solid var(--border); max-width: 720px; }
.hero-stats > div { display: flex; flex-direction: column; }
/* All four dt's share a fixed-height, bottom-aligned box so the dd labels
   below them start at the same line regardless of font-size/line-height
   differences between the numeric stats and the "Almost a decade" text stat. */
.hero-stats dt { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 700; color: var(--accent); margin: 0; min-height: 2.1rem; display: flex; align-items: flex-end; line-height: 1.1; }
.hero-stats dt.dt-text { font-family: var(--font-sans); font-size: 1.15rem; }
.hero-stats dd { margin: 4px 0 0; font-size: 0.8rem; color: var(--text-mute); }

/* --------------------------------------------------------------- how-work */

.how-work { padding: 8px 0 72px; }
.how-work-title { font-size: clamp(1.3rem, 2.6vw, 1.7rem); max-width: 620px; margin: 6px 0 0; }
.how-work-lede { margin: 10px 0 0; max-width: 620px; color: var(--text-dim); font-size: 0.98rem; }
.work-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 32px; }
.work-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px;
}
.work-stat { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; font-family: var(--font-mono); }
.work-before { font-size: 0.85rem; color: var(--text-mute); text-decoration: line-through; text-decoration-color: var(--border); }
.work-arrow { color: var(--accent-2); font-size: 0.9rem; }
/* flex-basis:100% forces "after" onto its own line every time, regardless of
   how long "before" is — without it, a short "before" (e.g. "22 process
   variants -> 1") could fit everything on one line while a longer one wraps,
   so the same before/after pattern read inconsistently card to card. */
.work-after { font-size: 1.05rem; font-weight: 700; color: var(--accent); flex-basis: 100%; }
.work-card p { margin: 0; font-size: 0.88rem; color: var(--text-dim); line-height: 1.5; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600;
  padding: 12px 22px; border-radius: 999px; font-size: 0.95rem; border: 1px solid transparent; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.link-btn {
  background: none; border: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline;
  cursor: pointer;
}

/* ---------------------------------------------------------------- section */

.section { padding: 80px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { display: flex; align-items: baseline; gap: 12px; font-size: clamp(1.5rem, 3vw, 2rem); }
.section-title .idx { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent-2); font-weight: 600; }
.sub-title { margin-top: 48px; font-size: 1.1rem; }
.lede { color: var(--text-dim); max-width: 640px; font-size: 1.05rem; }

/* ------------------------------------------------------------------ about */

.about-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; margin-top: 32px; }
.about-grid h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); margin-bottom: 10px; }
.pill-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill-list li {
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
  padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 500;
}

/* --------------------------------------------------------------- timeline */

.timeline { list-style: none; margin: 40px 0 0; padding: 0; border-left: 2px solid var(--border); max-width: 760px; }
.timeline-item { position: relative; padding: 0 0 40px 28px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.timeline-item .role { font-size: 1.05rem; font-weight: 700; margin: 0; }
.timeline-item .company { color: var(--accent-2); font-weight: 600; }
.timeline-item .dates { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-mute); margin: 2px 0 10px; }
.timeline-item ul { margin: 0; padding-left: 20px; color: var(--text-dim); font-size: 0.94rem; }
.timeline-item li { margin-bottom: 4px; }

/* ---------------------------------------------------------------- projects */

.project-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin-top: 36px;
  /* Grid's default (stretch) forces every card in a row to match the
     tallest one — a collapsed card next to an expanded one then had its
     "View case study" link pushed down into a large empty gap by the
     margin-top:auto below. align-items:start lets each card size to its
     own content instead, so the link always sits right under the stack. */
  align-items: start;
}
.project-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; cursor: pointer; transition: box-shadow 0.2s ease, transform 0.2s ease; display: flex; flex-direction: column;
}
.project-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.project-card h3 { font-size: 1.15rem; margin-bottom: 4px; }
.project-card .tagline { color: var(--text-dim); font-size: 0.92rem; margin-bottom: 14px; }
.project-card .stack { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.project-card .stack span {
  font-family: var(--font-mono); font-size: 0.72rem; background: var(--bg-alt); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 6px; color: var(--text-dim);
}
.project-card .expand-hint { margin-top: 2px; font-size: 0.82rem; color: var(--accent); font-weight: 600; }
.project-card .details { display: none; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); font-size: 0.92rem; }
.project-card.open .details { display: block; }
.project-card .details h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-mute); margin: 14px 0 6px; }
.project-card .details h4:first-child { margin-top: 0; }
.project-card .details ul { margin: 0; padding-left: 18px; color: var(--text-dim); }
.project-card .details p { color: var(--text-dim); margin: 0; }
.project-card .details a { color: var(--accent); font-weight: 600; }

/* ----------------------------------------------------------------- skills */

.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 32px; }
.skill-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.skill-card h3 { font-size: 0.95rem; margin-bottom: 12px; }
.skill-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.skill-card li { font-size: 0.82rem; background: var(--bg-alt); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; color: var(--text-dim); }

.cert-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.cert-list li { font-size: 0.9rem; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cert-list a { color: var(--text); text-decoration: none; font-weight: 500; }
.cert-list a:hover, .cert-list a:focus-visible { color: var(--accent); text-decoration: underline; }
.cert-list .cert-issuer { display: block; color: var(--text-mute); font-size: 0.8rem; margin-top: 2px; }

/* --------------------------------------------------------------- ask-ai */

.ask-ai { background: linear-gradient(180deg, var(--accent-soft), var(--bg)); }
.fit-form { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.fit-form label { font-size: 0.85rem; font-weight: 600; margin-top: 14px; }
.fit-form label:first-child { margin-top: 0; }
.fit-form textarea {
  font: inherit; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); resize: vertical;
}
.fit-form textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.cf-turnstile { margin: 18px 0 4px; }
.fit-form .btn { margin-top: 6px; align-self: flex-start; }
.form-hint { margin: 10px 0 0; font-size: 0.78rem; }
.form-hint a { color: var(--text-dim); text-decoration: underline; }
.form-hint a:hover, .form-hint a:focus-visible { color: var(--accent); }

.fit-result { max-width: 640px; margin-top: 20px; }
.fit-result-inner { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius-sm); padding: 20px; }
.fit-badge { display: inline-block; font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.fit-result p { margin: 0; white-space: pre-wrap; color: var(--text); }

.fit-error {
  max-width: 640px; margin-top: 20px; background: #fdeceb; border: 1px solid #f3b7b0; color: #7a2019;
  padding: 14px 16px; border-radius: var(--radius-sm); font-size: 0.9rem;
}
:root[data-theme="dark"] .fit-error { background: #2b1614; border-color: #5a2c26; color: #f3b7b0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fit-error { background: #2b1614; border-color: #5a2c26; color: #f3b7b0; }
}

/* ------------------------------------------------------------ ai-widget */

.ai-widget { position: fixed; right: 20px; bottom: 20px; z-index: 150; }

.ai-widget-panel {
  width: min(380px, calc(100vw - 40px)); max-height: min(780px, calc(100vh - 60px));
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.ai-widget[data-state="minimized"] .ai-widget-panel,
.ai-widget[data-state="closed"] .ai-widget-panel { display: none; }
.ai-widget[data-state="open"] .ai-widget-bubble { display: none; }
.ai-widget[data-state="closed"] .ai-widget-bubble { display: none; }

.ai-widget-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: var(--accent-soft); border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.ai-widget-title { font-weight: 700; font-size: 0.92rem; }
.ai-widget-controls { display: flex; gap: 6px; }
.ai-widget-btn {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); cursor: pointer; font-size: 1rem; line-height: 1; display: flex; align-items: center;
  justify-content: center; padding: 0; transition: border-color 0.15s ease, color 0.15s ease;
}
.ai-widget-btn:hover, .ai-widget-btn:focus-visible { border-color: var(--accent); color: var(--accent); }

.ai-widget-body {
  padding: 18px 16px 24px; overflow-y: auto;
  /* Without flex:1 + min-height:0, this flex child can grow past the panel's
     fixed max-height instead of scrolling within it — the panel's own
     overflow:hidden then silently clips whatever doesn't fit, cutting off
     the bottom of a long answer instead of making it scrollable. */
  flex: 1 1 auto; min-height: 0;
}
.ai-widget-lede { margin: 0 0 4px; font-size: 0.86rem; color: var(--text-dim); line-height: 1.5; }

.ai-widget-bubble {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border); background: var(--accent);
  color: #fff; font-size: 1.4rem; cursor: pointer; box-shadow: var(--shadow); display: flex; align-items: center;
  justify-content: center; transition: transform 0.15s ease;
}
.ai-widget-bubble:hover { transform: scale(1.06); }

@media (max-width: 480px) {
  .ai-widget { right: 12px; bottom: 12px; left: 12px; }
  .ai-widget-panel { width: 100%; }
  .ai-widget-bubble { margin-left: auto; }
}

/* ---------------------------------------------------------------- footer */

.site-footer { border-top: 1px solid var(--border); padding: 28px 0 32px; }
.footer-brand {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-bottom: 20px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border); color: var(--text-dim);
}
.ease-mark { color: var(--accent); flex-shrink: 0; }
.ease-name { font-weight: 800; font-size: 0.95rem; color: var(--text); letter-spacing: -0.01em; }
.ease-tagline {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-mute);
}
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-size: 0.85rem; color: var(--text-mute); }
.footer-links { display: flex; gap: 18px; }
.footer-links a { text-decoration: none; color: var(--text-dim); font-weight: 500; }
.footer-links a:hover { color: var(--accent); }

/* --------------------------------------------------------------- reveal */

.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.in-view { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------- mobile */

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

@media (max-width: 760px) {
  .nav { position: fixed; inset: 64px 0 0 0; background: var(--bg); flex-direction: column; align-items: flex-start; padding: 24px; gap: 18px; transform: translateX(100%); transition: transform 0.25s ease; }
  .nav.open { transform: translateX(0); }
  .nav-burger { display: flex; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .hero-stats dt { font-size: 1.4rem; min-height: 1.75rem; }
}
