/* ==========================================================================
   iambhav.in — computer-vision annotation theme
   zero JS · system fonts · built to load instantly
   ========================================================================== */

:root {
  --bg: #0a0c10;
  --panel: #0f1218;
  --line: #1d2330;
  --line-soft: #161b26;
  --text: #e7eaf0;
  --dim: #8b93a7;
  --faint: #565e72;
  --acc: #34f5a2;          /* detection green */
  --acc-ink: #04120b;      /* text on green */
  --acc-dim: rgba(52, 245, 162, 0.45);
  --amber: #ffb224;
  --cyan: #4cc9f0;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --wrap: 1080px;
  --measure: 68ch;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

body {
  background-color: var(--bg);
  /* camera-calibration grid */
  background-image:
    linear-gradient(rgba(139, 147, 167, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 147, 167, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--acc); color: var(--acc-ink); }

a { color: var(--text); text-decoration-color: var(--acc-dim); text-underline-offset: 3px; }
a:hover { color: var(--acc); }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 3px;
}

.mono { font-family: var(--mono); }
.dim { color: var(--dim); }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--acc); color: var(--acc-ink);
  padding: 0.5rem 1rem; z-index: 99; font-family: var(--mono);
}
.skip:focus { left: 0; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(1.1rem, 4vw, 2.5rem); }

/* --------------------------------------------------------------------------
   nav
   -------------------------------------------------------------------------- */

.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--wrap); margin: 0 auto;
  padding: 0.9rem clamp(1.1rem, 4vw, 2.5rem);
  background: rgba(10, 12, 16, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  font-family: var(--mono); font-weight: 700; font-size: 1rem;
  text-decoration: none; letter-spacing: 0.02em;
}
.brand-cursor { color: var(--acc); animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.nav nav { display: flex; flex-wrap: wrap; gap: 0.5rem clamp(0.9rem, 2.5vw, 1.8rem); justify-content: flex-end; }
.nav-toggle, .nav-burger { display: none; }
.nav nav a {
  font-family: var(--mono); font-size: 0.8rem; text-decoration: none;
  color: var(--dim); letter-spacing: 0.03em;
}
.nav nav a:hover { color: var(--acc); }
.nav nav .n { color: var(--faint); margin-right: 0.4em; font-size: 0.7rem; }

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

.hero {
  max-width: var(--wrap); margin: 0 auto;
  padding: clamp(4rem, 12vh, 8rem) clamp(1.1rem, 4vw, 2.5rem) clamp(3rem, 8vh, 5rem);
}

.kicker {
  font-family: var(--mono); font-size: 0.78rem; color: var(--faint);
  letter-spacing: 0.05em; margin-bottom: 2.2rem;
}
.kicker b { color: var(--acc); font-weight: 400; }

.bbox {
  position: relative; display: inline-block;
  padding: clamp(1.2rem, 4vw, 2.6rem) clamp(1.4rem, 5vw, 3.2rem);
  border: 1px dashed var(--acc-dim);
  margin-top: 1.4rem;
}
.bbox-label {
  position: absolute; top: 0; left: -1px; transform: translateY(-100%);
  background: var(--acc); color: var(--acc-ink);
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.04em; padding: 0.4em 0.7em; white-space: nowrap;
}
.bbox-label em { font-style: normal; opacity: 0.65; margin-left: 0.6em; }
.corner { position: absolute; width: 15px; height: 15px; border: 2px solid var(--acc); }
.c-tl { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.c-tr { top: -2px; right: -2px; border-left: 0; border-bottom: 0; }
.c-bl { bottom: -2px; left: -2px; border-right: 0; border-top: 0; }
.c-br { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

.hero h1 {
  font-size: clamp(2.9rem, 12vw, 7rem);
  line-height: 0.95; letter-spacing: -0.03em; font-weight: 800;
}

.lede {
  max-width: 42ch; margin-top: 2.4rem;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem); line-height: 1.55; color: var(--dim);
}
.lede strong { color: var(--text); font-weight: 600; }

.readout {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.8rem;
  margin-top: 2.6rem;
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.03em;
}
.readout span { color: var(--faint); }
.readout b { color: var(--text); font-weight: 400; }
.readout .ok { color: var(--acc); }

/* --------------------------------------------------------------------------
   lane divider — a nod to lane detection
   -------------------------------------------------------------------------- */

.lane {
  border: 0; height: 3px; margin: clamp(3rem, 8vh, 5.5rem) auto;
  max-width: var(--wrap);
  background: repeating-linear-gradient(90deg, var(--acc-dim) 0 32px, transparent 32px 60px);
  opacity: 0.3;
}

/* --------------------------------------------------------------------------
   sections
   -------------------------------------------------------------------------- */

.sec { max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(1.1rem, 4vw, 2.5rem); }

.sec-head { margin-bottom: 2.4rem; }
.sec-head .kicker { margin-bottom: 0.7rem; }
.sec-title {
  font-size: clamp(1.7rem, 5vw, 2.5rem);
  letter-spacing: -0.02em; font-weight: 750;
}

.prose { color: var(--dim); }
.prose p + p { margin-top: 1.1rem; }
.prose strong, .prose a { color: var(--text); }
.prose a:hover { color: var(--acc); }

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

.timeline { border-left: 1px dashed var(--line); padding-left: 2rem; }

.titem { position: relative; padding-bottom: 2.6rem; }
.titem:last-child { padding-bottom: 0.5rem; }
.titem::before {
  content: ""; position: absolute; left: calc(-2rem - 6px); top: 0.5rem;
  width: 9px; height: 9px; background: var(--bg); border: 2px solid var(--acc);
}
.titem .when {
  font-family: var(--mono); font-size: 0.75rem; color: var(--faint);
  letter-spacing: 0.05em;
}
.titem h3 { font-size: 1.15rem; margin: 0.35rem 0 0.2rem; font-weight: 650; }
.titem .org { color: var(--dim); font-size: 0.95rem; }
.titem .org a { color: var(--dim); }
.titem ul { margin: 0.8rem 0 0 1.1rem; color: var(--dim); font-size: 0.95rem; }
.titem li { margin-bottom: 0.4rem; }
.titem li::marker { color: var(--acc-dim); }

/* --------------------------------------------------------------------------
   project cards — detections
   -------------------------------------------------------------------------- */

.grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.card {
  position: relative; display: block;
  background: var(--panel); border: 1px solid var(--line);
  padding: 1.4rem 1.4rem 1.2rem; text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card::after {
  content: attr(data-conf);
  position: absolute; top: 0.7rem; right: 0.7rem;
  font-family: var(--mono); font-size: 0.65rem; color: var(--acc);
  border: 1px solid var(--acc-dim); padding: 2px 7px;
  opacity: 0; transition: opacity 0.2s ease;
}
.card:hover, .card:focus-visible {
  border-color: var(--acc-dim); transform: translateY(-3px);
}
.card:hover::after, .card:focus-visible::after { opacity: 1; }
.card h3 { font-size: 1.05rem; font-weight: 650; color: var(--text); }
.card p { margin-top: 0.55rem; font-size: 0.9rem; color: var(--dim); line-height: 1.55; }
.card .tags {
  display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 1rem;
  font-family: var(--mono); font-size: 0.68rem; color: var(--faint);
}
.card .tags span { border: 1px solid var(--line); padding: 2px 7px; }

/* --------------------------------------------------------------------------
   papers
   -------------------------------------------------------------------------- */

.papers { }
.paper {
  display: block; padding: 1.3rem 0; border-top: 1px solid var(--line-soft);
  text-decoration: none;
}
.paper:last-child { border-bottom: 1px solid var(--line-soft); }
.paper .venue {
  font-family: var(--mono); font-size: 0.7rem; color: var(--amber);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.paper h3 { font-size: 1.05rem; font-weight: 650; margin: 0.4rem 0 0.3rem; color: var(--text); }
.paper:hover h3 { color: var(--acc); }
.paper p { font-size: 0.9rem; color: var(--dim); }

/* --------------------------------------------------------------------------
   writing list (home + blog index)
   -------------------------------------------------------------------------- */

.year {
  font-family: var(--mono); font-size: clamp(1.6rem, 5vw, 2.2rem);
  color: var(--line); -webkit-text-stroke: 1px var(--dim);
  letter-spacing: 0.04em; margin: 2.6rem 0 0.6rem;
}
.year:first-of-type { margin-top: 1.5rem; }

.post-list { list-style: none; }
.post-list li { border-top: 1px solid var(--line-soft); }
.post-list li:last-child { border-bottom: 1px solid var(--line-soft); }
.post-list a {
  display: flex; align-items: baseline; gap: 1.2rem;
  padding: 1rem 0.2rem; text-decoration: none;
}
.post-list .date {
  font-family: var(--mono); font-size: 0.75rem; color: var(--faint);
  flex-shrink: 0; width: 4.2rem;
}
.post-list .ptitle { font-weight: 550; }
.post-list a:hover .ptitle { color: var(--acc); }
.post-list .read {
  margin-left: auto; font-family: var(--mono); font-size: 0.7rem;
  color: var(--faint); flex-shrink: 0;
}

.empty { color: var(--faint); font-family: var(--mono); font-size: 0.85rem; }

/* --------------------------------------------------------------------------
   blog post page
   -------------------------------------------------------------------------- */

.post { padding-top: clamp(3rem, 8vh, 5rem); padding-bottom: 4rem; }
.post-head { margin-bottom: 2.5rem; }
.post-title {
  font-size: clamp(1.9rem, 6vw, 3.1rem); line-height: 1.1;
  letter-spacing: -0.02em; font-weight: 780; margin: 0.6rem 0 1rem;
}
.post-meta { font-size: 0.78rem; color: var(--faint); }
.post-meta .tag {
  display: inline-block; margin-left: 0.6rem; padding: 1px 8px;
  border: 1px solid var(--line); color: var(--dim); font-size: 0.68rem;
}

.post-body { max-width: var(--measure); font-size: 1.02rem; color: #c8cdda; }
.post-body h2, .post-body h3 {
  color: var(--text); letter-spacing: -0.01em;
  margin: 2.2rem 0 0.8rem;
}
.post-body h2 { font-size: 1.45rem; }
.post-body h3 { font-size: 1.15rem; }
.post-body h2::before, .post-body h3::before {
  content: "// "; color: var(--acc-dim); font-family: var(--mono);
  font-size: 0.85em;
}
.post-body p { margin: 1rem 0; }
.post-body a { color: var(--text); }
.post-body a:hover { color: var(--acc); }
.post-body ul, .post-body ol { margin: 1rem 0 1rem 1.4rem; }
.post-body li { margin-bottom: 0.4rem; }
.post-body li::marker { color: var(--acc-dim); }
.post-body blockquote {
  border-left: 3px solid var(--acc-dim); padding-left: 1.2rem;
  margin: 1.4rem 0; color: var(--dim); font-style: italic;
}
.post-body img { max-width: 100%; height: auto; border: 1px solid var(--line); }
.post-body hr {
  border: 0; height: 3px; margin: 2.5rem 0;
  background: repeating-linear-gradient(90deg, var(--acc-dim) 0 24px, transparent 24px 46px);
  opacity: 0.3;
}
.post-body code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--panel); border: 1px solid var(--line);
  padding: 0.1em 0.35em;
}
.post-body pre {
  background: var(--panel); border: 1px solid var(--line);
  padding: 1.1rem 1.2rem; overflow-x: auto; margin: 1.3rem 0;
  font-size: 0.85rem; line-height: 1.55;
}
.post-body pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.post-body table { border-collapse: collapse; margin: 1.3rem 0; width: 100%; font-size: 0.9rem; }
.post-body th, .post-body td { border: 1px solid var(--line); padding: 0.5rem 0.8rem; text-align: left; }
.post-body th { font-family: var(--mono); font-size: 0.75rem; color: var(--dim); }

.post-foot { margin-top: 3.5rem; }
.backlink { font-size: 0.8rem; color: var(--dim); text-decoration: none; }
.backlink:hover { color: var(--acc); }

/* rouge syntax highlighting — minimal */
.highlight .c, .highlight .c1, .highlight .cm { color: var(--faint); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn { color: var(--cyan); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb { color: var(--acc); }
.highlight .m, .highlight .mi, .highlight .mf { color: var(--amber); }
.highlight .nf, .highlight .fm { color: #b197fc; }
.highlight .nb, .highlight .bp { color: var(--cyan); }
.highlight .o, .highlight .ow { color: var(--dim); }

/* --------------------------------------------------------------------------
   contact
   -------------------------------------------------------------------------- */

.contact { padding-bottom: 1rem; }
.contact-box {
  position: relative; border: 1px dashed var(--acc-dim);
  padding: clamp(1.8rem, 5vw, 3rem);
}
.contact-box .bbox-label { left: -1px; }
.contact-box h2 {
  font-size: clamp(1.5rem, 4.5vw, 2.2rem); letter-spacing: -0.02em;
  font-weight: 750; margin-bottom: 0.8rem;
}
.contact-box p { color: var(--dim); }
.email {
  display: inline-block; margin-top: 1.6rem;
  font-family: var(--mono); font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  color: var(--acc); text-decoration: none;
  border-bottom: 1px dashed var(--acc-dim); padding-bottom: 2px;
}
.email:hover { border-bottom-style: solid; }

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

.footer { border-top: 1px solid var(--line-soft); margin-top: clamp(3rem, 8vh, 5rem); }
.footer-inner {
  max-width: var(--wrap); margin: 0 auto;
  padding: 1.6rem clamp(1.1rem, 4vw, 2.5rem);
  display: flex; flex-wrap: wrap; gap: 0.8rem 2rem; align-items: center;
  font-size: 0.72rem;
}
.social { list-style: none; display: flex; gap: 1.2rem; margin-left: auto; }
.social a {
  font-family: var(--mono); font-size: 0.72rem; color: var(--dim);
  text-decoration: none;
}
.social a:hover { color: var(--acc); }

/* --------------------------------------------------------------------------
   404
   -------------------------------------------------------------------------- */

.nf-wrap { text-align: center; padding: clamp(5rem, 20vh, 10rem) 1.5rem; }
.nf-wrap .bbox { margin-top: 2rem; }
.nf-wrap h1 { font-size: clamp(3rem, 14vw, 7rem); font-weight: 800; letter-spacing: -0.03em; }
.nf-wrap p { margin-top: 2rem; color: var(--dim); }

/* --------------------------------------------------------------------------
   motion — subtle scroll reveals where supported
   -------------------------------------------------------------------------- */

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero > * { animation: rise 0.55s ease both; }
.hero > *:nth-child(2) { animation-delay: 0.07s; }
.hero > *:nth-child(3) { animation-delay: 0.14s; }
.hero > *:nth-child(4) { animation-delay: 0.21s; }

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .card, .titem, .paper {
      animation: rise 0.5s ease both;
      animation-timeline: view();
      animation-range: entry 0% entry 35%;
    }
  }
}

/* --------------------------------------------------------------------------
   small screens
   -------------------------------------------------------------------------- */

@media (max-width: 640px) {
  body { background-size: 40px 40px; }
  .nav { flex-wrap: wrap; }
  .nav-burger {
    display: block; position: relative; width: 22px; height: 16px; cursor: pointer;
  }
  .nav-burger span, .nav-burger::before, .nav-burger::after {
    content: ""; position: absolute; left: 0; width: 100%; height: 2px;
    background: var(--text);
    transition: transform 0.25s ease, opacity 0.2s ease, top 0.25s ease;
  }
  .nav-burger::before { top: 0; }
  .nav-burger span { top: 7px; }
  .nav-burger::after { top: 14px; }
  .nav-toggle:checked + .nav-burger::before { top: 7px; transform: rotate(45deg); }
  .nav-toggle:checked + .nav-burger span { opacity: 0; }
  .nav-toggle:checked + .nav-burger::after { top: 7px; transform: rotate(-45deg); }
  .nav nav { display: none; }
  .nav-toggle:checked ~ nav {
    display: flex; flex-direction: column; flex-basis: 100%;
    gap: 0; margin-top: 0.9rem; padding-top: 0.5rem;
    border-top: 1px dashed var(--line);
  }
  .nav nav a { padding: 0.6rem 0; font-size: 0.85rem; }
  .timeline { padding-left: 1.4rem; }
  .titem::before { left: calc(-1.4rem - 5px); }
  .post-list .read { display: none; }
  .readout { flex-direction: column; gap: 0.45rem; }
}
