/* algofunds portfolio.
   Premium dark engineering aesthetic. Single lime accent, used sparingly.
   All design decisions live in the tokens below. Do not scatter raw values. */

:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #08090A;
  --bg-2: #0D0F11;
  --surface: #111417;
  --surface-hover: #15191D;
  --code-bg: #0A0C0E;
  --grid-line: rgba(255, 255, 255, 0.016);

  /* borders */
  --border: #23272B;
  --border-subtle: #1A1D20;
  --border-hover: #343A40;
  --border-btn: #2A2F34;

  /* text */
  --text: #F5F7F9;
  --text-2: #A7ADB5;
  --muted: #6F7780;
  --disabled: #4B5158;

  /* accent. --accent is for fills (button, dots); --accent-text is the
     contrast-safe variant for text and thin strokes on the current surface. */
  --accent: #A3FF12;
  --accent-hover: #B8FF45;
  --accent-text: #A3FF12;
  --accent-bg: rgba(163, 255, 18, 0.08);
  --accent-border: rgba(163, 255, 18, 0.25);
  --accent-ink: #0A0C0E;

  /* type */
  --font-sans: "Geist", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* layout */
  --maxw: 1200px;
  --pad: 24px;

  /* radii */
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;

  /* elevation */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);

  /* motion */
  --t-fast: 180ms;
  --t: 220ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* rhythm */
  --section-gap: clamp(76px, 12vw, 148px);

  /* expo-out easing for the theme reveal */
  --expo-out: linear(
    0 0%, 0.1684 2.66%, 0.3165 5.49%, 0.446 8.52%,
    0.5581 11.78%, 0.6535 15.29%, 0.7341 19.11%, 0.8011 23.3%,
    0.8557 27.93%, 0.8962 32.68%, 0.9283 38.01%, 0.9529 44.08%,
    0.9711 51.14%, 0.9833 59.06%, 0.9915 68.74%, 1 100%
  );
}

/* Light theme. Dark is the default (:root above); this is the opt-in surface.
   Fills keep the vivid lime; text/strokes use a darkened lime for contrast. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #FCFCFB;
  --bg-2: #F5F6F7;
  --surface: #FFFFFF;
  --surface-hover: #F0F2F4;
  --code-bg: #F5F6F7;
  --grid-line: rgba(10, 20, 30, 0.028);

  --border: #E4E7EA;
  --border-subtle: #ECEEF0;
  --border-hover: #CFD5DB;
  --border-btn: #D7DBE0;

  --text: #0B0D0F;
  --text-2: #4C555F;
  --muted: #737C86;
  --disabled: #AAB1B9;

  --accent: #A3FF12;
  --accent-hover: #93E80D;
  --accent-text: #3F6212;
  --accent-bg: rgba(101, 163, 13, 0.10);
  --accent-border: rgba(101, 163, 13, 0.30);
  --accent-ink: #0A0C0E;

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "cv01", "ss01";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* barely-there technical grid, dissolves into the background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 100% 60% at 50% 0%, #000 20%, transparent 75%);
}

main { position: relative; z-index: 1; }

a { color: inherit; text-decoration: none; }

.mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  font-feature-settings: normal;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: var(--pad); }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: 0 0 var(--r-sm) 0; font-weight: 600;
}
.skip:focus { left: 0; }

:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: 3px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(10px) saturate(120%);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 14px var(--pad);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.mark { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.mark-node {
  width: 9px; height: 9px; border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 55%, transparent);
}
.topnav { display: flex; align-items: center; gap: clamp(16px, 2.4vw, 30px); }
.topnav a {
  color: var(--text-2); font-size: 0.9rem; font-weight: 450;
  display: inline-flex; align-items: center; gap: 6px;
  transition: color var(--t-fast) var(--ease);
}
.topnav a:hover { color: var(--text); }
.topnav a.active { color: var(--text); }
.topnav a.active::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.theme-toggle {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  padding: 0; margin-left: 4px; cursor: pointer; color: var(--text-2);
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm);
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface); }
.theme-toggle .icon { width: 17px; height: 17px; grid-area: 1 / 1; }
.theme-toggle .moon { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }

/* ---------- hero ---------- */
.hero { position: relative; padding-top: clamp(72px, 13vw, 150px); padding-bottom: var(--section-gap); overflow: hidden; }
.hero::before {
  content: ""; position: absolute; z-index: 0; left: 50%; top: -120px; translate: -50% 0;
  width: min(880px, 96vw); height: 520px;
  background: radial-gradient(ellipse at center, var(--accent-bg), transparent 68%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 26px;
}
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

h1 {
  font-family: var(--font-sans); color: var(--text);
  font-weight: 600; font-size: clamp(2.6rem, 7vw, 5rem); line-height: 1.0; letter-spacing: -0.045em;
  margin: 0 0 26px; max-width: 16ch;
}
.lede { max-width: 60ch; margin: 0 0 34px; font-size: clamp(1rem, 1.5vw, 1.16rem); color: var(--text-2); }
.lede .mono { color: var(--text); }

.hero-meta {
  display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 0 0 36px;
  font-family: var(--font-mono); font-size: 0.76rem; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase;
}
.hero-meta span { display: inline-flex; align-items: center; gap: 8px; }
.hero-meta b { color: var(--text); font-weight: 500; }

.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-sans); font-size: 0.92rem; font-weight: 500;
  padding: 10px 16px; border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  min-height: 40px;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; border-color: var(--border-btn); color: var(--text); }
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface); }
.btn .arrow { transition: transform var(--t-fast) var(--ease); }
.btn:hover .arrow { transform: translate(3px, -3px); }

/* ---------- section headers ---------- */
section { position: relative; }
.section { padding-bottom: var(--section-gap); }
.section-head {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: clamp(28px, 4vw, 48px);
  padding-bottom: 20px; border-bottom: 1px solid var(--border-subtle);
}
.section-num { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); letter-spacing: 0.04em; padding-top: 4px; }
.section-title { font-family: var(--font-sans); color: var(--text); font-weight: 600; font-size: clamp(1.3rem, 2.6vw, 1.9rem); letter-spacing: -0.03em; margin: 0; text-transform: uppercase; }
.section-sub { color: var(--muted); font-size: 0.95rem; margin: 0 0 0 auto; max-width: 34ch; text-align: right; }

/* ---------- project grid ---------- */
.grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }

.card {
  position: relative; display: flex; flex-direction: column; gap: 16px;
  padding: 22px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  transition: transform var(--t) var(--ease), border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.card:hover { transform: translateY(-2px); border-color: var(--border-hover); background: var(--surface); }
.card-hit { position: absolute; inset: 0; z-index: 1; border-radius: var(--r-lg); }
.card-hit:focus-visible { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.card > *:not(.card-hit) { position: relative; z-index: 2; pointer-events: none; }

.card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; color: var(--muted); }
.status { display: inline-flex; align-items: center; gap: 7px; text-transform: uppercase; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 7px color-mix(in srgb, var(--accent) 60%, transparent); }
/* shipped, but not hosted at a live URL: quiet the dot so "live" stays honest */
.status[data-tone="muted"] .status-dot { background: var(--muted); box-shadow: none; }
.card-cat { color: var(--text-2); text-transform: uppercase; }

.card-name { font-family: var(--font-sans); color: var(--text); font-weight: 600; font-size: 1.32rem; letter-spacing: -0.025em; margin: 0; }
.card-desc { margin: 0; color: var(--text-2); font-size: 0.95rem; flex: 1; }
.tech { display: flex; flex-wrap: wrap; gap: 6px 10px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.tech span { display: inline-flex; align-items: center; }
.tech span + span::before { content: "·"; margin-right: 10px; color: var(--disabled); }

.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; border-top: 1px solid var(--border-subtle); margin-top: 2px; }
.card-view { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.08em; color: var(--text); text-transform: uppercase; }
.card-view .arrow { transition: transform var(--t-fast) var(--ease); }
.card:hover .card-view { color: var(--accent-text); }
.card:hover .card-view .arrow { transform: translateX(4px); }
.card-foot-right { display: inline-flex; align-items: center; gap: 14px; }
.card-year { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }

/* ---------- platform marks ---------- */
.picon { width: 15px; height: 15px; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; transition: color var(--t-fast) var(--ease); }
.picon-fill { fill: currentColor; stroke: none; }
.plats { display: inline-flex; align-items: center; gap: 9px; }
.card:hover .plats .picon { color: var(--text-2); }
.plat-list { display: flex; flex-direction: column; gap: 2px; }
.plat-list span { display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-2); padding: 6px 0; border-bottom: 1px solid var(--border-subtle); }
.plat-list span:last-child { border-bottom: 0; }
.plat-list .picon { color: var(--text-2); }

/* ---------- systems ---------- */
.systems { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); gap: 18px; }
.sys {
  padding: 22px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-2); transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
.sys:hover { border-color: var(--border-hover); background: var(--surface); }
.sys-k { display: block; font-family: var(--font-mono); font-size: 0.76rem; color: var(--accent-text); letter-spacing: 0.06em; margin-bottom: 16px; }
.sys h3 { font-family: var(--font-sans); color: var(--text); font-weight: 600; font-size: 1.02rem; letter-spacing: -0.015em; margin: 0 0 8px; }
.sys p { margin: 0; color: var(--text-2); font-size: 0.9rem; }
.sys-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; font-family: var(--font-mono); font-size: 0.73rem; letter-spacing: 0.06em; color: var(--accent-text); transition: gap var(--t-fast) var(--ease); }
.sys-link .icon { width: 14px; height: 14px; }
.sys-link:hover { gap: 9px; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--border-subtle); }
.foot-inner {
  max-width: var(--maxw); margin: 0 auto; padding: clamp(34px, 5vw, 52px) var(--pad) 28px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px;
}
.foot-brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 600; letter-spacing: -0.02em; }
.foot-by { margin: 0; color: var(--muted); font-size: 0.92rem; flex: 1; min-width: 220px; }
.foot-by a { color: var(--text-2); border-bottom: 1px solid var(--accent-border); transition: color var(--t-fast) var(--ease); }
.foot-by a:hover { color: var(--accent-text); }
.foot-links { display: flex; gap: 6px; }
.foot-links a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-sm); color: var(--muted);
  border: 1px solid transparent; transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.foot-links a:hover { color: var(--text); border-color: var(--border); background: var(--surface); }
.foot-note { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--pad) 30px; color: var(--muted); font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; }

/* ---------- detail pages ---------- */
.detail { padding-top: clamp(30px, 5vw, 52px); }
.detail-wrap { max-width: 920px; margin: 0 auto; padding-inline: var(--pad); }
.back { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: clamp(28px, 4vw, 44px); transition: color var(--t-fast) var(--ease), gap var(--t-fast) var(--ease); }
.back:hover { color: var(--text); gap: 12px; }
.back .arrow { transition: transform var(--t-fast) var(--ease); }
.back:hover .arrow { transform: translateX(-3px); }

.detail-hero { padding-bottom: clamp(28px, 4vw, 44px); border-bottom: 1px solid var(--border-subtle); }
.detail-metaline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 18px; }
.detail-metaline .status { color: var(--text-2); }
.detail-hero h1 { font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1.02; margin: 0 0 14px; max-width: none; }
.detail-tagline { font-family: var(--font-sans); font-weight: 500; font-size: clamp(1.05rem, 2.2vw, 1.4rem); letter-spacing: -0.02em; color: var(--accent-text); margin: 0 0 20px; }
.detail-summary { max-width: 62ch; color: var(--text-2); font-size: 1.05rem; margin: 0 0 28px; }
.detail-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.detail-addr { font-family: var(--font-mono); font-size: 0.82rem; color: var(--muted); }

.detail-body { display: grid; grid-template-columns: 1.5fr 1fr; gap: clamp(28px, 5vw, 60px); padding: clamp(32px, 5vw, 56px) 0; }
.block-title { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 18px; }
.feature-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feature-list li { position: relative; padding: 14px 0 14px 26px; color: var(--text); font-size: 1rem; border-bottom: 1px solid var(--border-subtle); }
.feature-list li:first-child { padding-top: 0; }
.feature-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.feature-list li::before { content: ""; position: absolute; left: 0; top: 1.35em; width: 6px; height: 6px; border-radius: 1px; background: var(--accent); }
.feature-list li:first-child::before { top: 0.55em; }

.detail-side { display: flex; flex-direction: column; gap: 20px; }
.panel { padding: 20px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg-2); }
.panel p { margin: 0; color: var(--text-2); font-size: 0.94rem; }
.stack-list { display: flex; flex-direction: column; gap: 2px; }
.stack-list span { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-2); padding: 6px 0; border-bottom: 1px solid var(--border-subtle); }
.stack-list span:last-child { border-bottom: 0; }

.detail-nav { display: flex; justify-content: space-between; gap: 14px; border-top: 1px solid var(--border-subtle); padding: clamp(24px, 4vw, 34px) 0 clamp(24px, 5vw, 44px); }
.detail-nav-link { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); transition: color var(--t-fast) var(--ease); }
.detail-nav-link .mono { color: var(--muted); }
.detail-nav-link .np-name { font-family: var(--font-sans); font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.detail-nav-link.is-next { text-align: right; align-items: flex-end; }
.detail-nav-link:hover .np-name { color: var(--accent-text); }

/* ---------- 404 ---------- */
.nf { text-align: center; padding: clamp(60px, 12vw, 130px) var(--pad); max-width: 620px; margin: 0 auto; }
.nf .eyebrow { justify-content: center; }
.nf h1 { max-width: none; font-size: clamp(2rem, 6vw, 3.2rem); margin: 0 auto 14px; }
.nf p { color: var(--muted); margin: 0 auto 28px; }

/* ---------- reveal (only hidden when JS is present) ---------- */
.js .reveal { opacity: 0; transform: translateY(12px); }
.js .reveal.in { opacity: 1; transform: none; transition: opacity 420ms var(--ease), transform 420ms var(--ease); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  :root { --pad: 18px; }
  .detail-body { grid-template-columns: 1fr; }
  .section-sub { display: none; }
  .topnav .nav-hide { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .sys, .btn, .card-view .arrow, .btn .arrow, .back .arrow { transition: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- theme reveal (circle-blur via View Transitions) ---------- */
@media not (prefers-reduced-motion: reduce) {
  ::view-transition-group(root) { animation-timing-function: var(--expo-out); }

  :root:active-view-transition-type(circle-blur)::view-transition-old(root) {
    animation: none;
    animation-fill-mode: both;
    z-index: -1;
  }
  :root:active-view-transition-type(circle-blur)::view-transition-new(root) {
    clip-path: circle(0% at var(--toggle-x, 50%) var(--toggle-y, 50%));
    animation: circle-blur-reveal 0.62s;
    animation-fill-mode: both;
  }

  @keyframes circle-blur-reveal {
    0% { clip-path: circle(0% at var(--toggle-x, 50%) var(--toggle-y, 50%)); filter: blur(6px); }
    70% { filter: blur(0); }
    100% { clip-path: circle(140vmax at var(--toggle-x, 50%) var(--toggle-y, 50%)); filter: blur(0); }
  }
}
