/* ivikkk.xyz — editorial styles (Sequoia-article-inspired, original implementation) */

:root {
  --bg: #f6f2ea;
  --ink: #191713;
  --muted: #6e675c;
  --hair: #d9d3c5;
  --accent: #b0490f;
  --code-bg: #eee8db;
  --paper: #fbf9f4;
}

[data-theme="dark"] {
  --bg: #141310;
  --ink: #eae5da;
  --muted: #928b7c;
  --hair: #2e2b24;
  --accent: #e0793d;
  --code-bg: #1e1c17;
  --paper: #f3efe6;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-optical-sizing: auto;
  font-size: 1.1875rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.mono, nav, .kicker, .meta, .caption, .project-links, .notice, footer, .toc, .btn {
  font-family: "Fragment Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

a { color: inherit; text-decoration: underline; text-decoration-color: var(--hair); text-underline-offset: 3px; transition: color 0.15s ease, text-decoration-color 0.15s ease; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }

::selection { background: var(--accent); color: var(--bg); }

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

header {
  border-bottom: 1px solid var(--hair);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.wordmark {
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--accent);
}
.wordmark:hover { color: var(--accent); }

.header-left { display: flex; align-items: center; gap: 1.6rem; }

nav { display: flex; align-items: center; gap: 1.4rem; font-size: 0.8rem; }
nav a { text-decoration: none; color: var(--muted); }
nav a:hover { color: var(--accent); }

.nav-sections { gap: 1.2rem; }
nav a.nav-btn {
  color: var(--ink);
  transition: color 0.15s ease;
}
nav a.nav-btn:hover { color: var(--accent); }
nav .only-sm { display: none; }

#theme-toggle {
  background: none;
  border: 1px solid var(--hair);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  transition: border-color 0.15s ease, color 0.15s ease;
  flex: none;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
#theme-toggle svg { width: 15px; height: 15px; }
#theme-toggle .moon { display: none; }
[data-theme="dark"] #theme-toggle .sun { display: none; }
[data-theme="dark"] #theme-toggle .moon { display: block; }

/* ---------- index page ---------- */

.home {
  /* one shared column for projects, research, and talks — between the old
     780px home column and the 1080px research breakout */
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1.5rem 5rem;
}

.hero { padding: 2.6rem 0 0.4rem; }

.kicker {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}
.kicker .accent { color: var(--accent); }

.hero h1 {
  font-weight: 460;
  font-size: 1.25rem;
  line-height: 1.45;
  letter-spacing: 0;
  margin-bottom: 1rem;
  color: var(--accent);
  text-align: center;
  text-wrap: balance;
}
.hero h1 em { font-style: italic; color: var(--accent); }

.notice {
  margin-top: 1.4rem;
  font-size: 0.78rem;
  color: var(--muted);
  border-left: 2px solid var(--accent);
  padding-left: 0.9rem;
  line-height: 1.7;
}

section { padding: 1.1rem 0 1.6rem; border-top: 1px solid var(--hair); }
#research {
  border-top: none;
}

.section-label {
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: inline-block;
  background: var(--bg);
  padding-right: 0.7rem;
  margin: calc(-1.1rem - 0.62rem) 0 0.5rem;
  transition: background-color 0.25s ease;
}
.section-label::before { content: "— "; color: var(--accent); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.7rem;
  margin-top: 0.4rem;
}
.tile {
  border: 1px solid var(--hair);
  border-radius: 4px;
  padding: 0.8rem 0.95rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s ease;
}
.tile:hover { border-color: var(--accent); }
.tile-name {
  font-family: "Fragment Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: var(--accent);
}
.tile-desc {
  font-size: 0.95rem;
  line-height: 1.45;
  flex: 1;
}
.tile-links {
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.tile-links a { text-decoration: none; color: var(--muted); }
.tile-links a:hover { color: var(--accent); }
.tile-links .link-prefix { color: var(--muted); }

.paper-card { display: block; text-decoration: none; padding: 1.05rem 0; }
.paper-card + .paper-card { border-top: 1px solid var(--hair); }
.paper-card .meta { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.paper-card h3 { font-weight: 480; font-size: 1.45rem; line-height: 1.25; margin-bottom: 0.45rem; }
.paper-card p.abstract { color: var(--muted); font-size: 1rem; }
.paper-card .read { display: inline-block; margin-top: 0.5rem; font-family: "Fragment Mono", ui-monospace, monospace; font-size: 0.78rem; color: var(--accent); }
.paper-card:hover h3 { color: var(--accent); }
.paper-card.has-thumb { display: flex; align-items: center; gap: 2.2rem; }
.paper-card .card-text { flex: 1; min-width: 0; }
/* no frame: card art is authored to look right as-is, rendered edge-to-edge
   at its own aspect ratio */
.card-plate {
  flex-shrink: 0;
  width: 300px;
  border-radius: 3px;
  overflow: hidden;
}
.card-plate img { display: block; width: 100%; height: auto; }
@media (max-width: 900px) {
  .paper-card.has-thumb { gap: 1.6rem; }
  .card-plate { width: 240px; }
}
@media (max-width: 640px) {
  .paper-card.has-thumb { flex-direction: column-reverse; align-items: stretch; gap: 1rem; }
  .card-plate { width: 100%; }
}

/* year dividers span the full grid row */
.talks-year {
  grid-column: 1 / -1;
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  border-bottom: 1px solid var(--hair);
  padding-bottom: 0.35rem;
  margin-top: 0.6rem;
}
.talks-year:first-child { margin-top: 0; }

/* magazine grid: photo on top at full column width, text below */
.talks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.2rem 2.4rem;
  margin-top: 0.6rem;
}
/* talks are photographs — cover-crop into the same plate language as research */
.talk-photo {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--hair);
  border-radius: 3px;
  margin-bottom: 0.9rem;
}
/* photo-less talks keep the grid rhythm with a typographic stub plate */
.talk-stub {
  background: var(--code-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.talk-stub span {
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}
@media (max-width: 640px) {
  .talks-grid { grid-template-columns: 1fr; }
}
/* card order: event title, location line, role chip */
.talk-title {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.3;
}
.talk-title .talk-type { margin-bottom: 0.15rem; }
.talk-loc {
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0.15rem 0 0.3rem;
}
/* who shared the stage — closing line of the card. Flex-wrapped so each name
   carries a "·" in the gap to its left (::before, absolutely positioned);
   overflow:hidden clips the dot when its name starts a new line, so separators
   only ever appear between names on the same line. */
.talk-meta {
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  line-height: 1.9;
  margin-top: 0.35rem;
  display: flex;
  flex-wrap: wrap;
  column-gap: 1em;
  overflow: hidden;
}
.stage-label { color: var(--muted); margin-right: -0.55em; }
.talk-meta a + a { position: relative; }
.talk-meta a + a::before {
  content: "·";
  position: absolute;
  /* center the monospace glyph box (~0.6em advance) in the 1em column gap */
  left: -0.8em;
  color: var(--muted);
}
.talk-type {
  display: inline-block;
  font-size: 0.68rem;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 2px;
  padding: 0.4rem 0.4rem 0;
}
.talk-meta a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dotted var(--muted);
  /* never break inside a company name — wrap the whole name to the next line */
  white-space: nowrap;
}
.talk-meta a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.talk-desc { font-size: 0.92rem; color: var(--muted); }
/* links live on their own quiet line under the desc */
.talk-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  margin-top: 0.35rem;
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.75rem;
}
.talk-links a { text-decoration: none; color: var(--muted); }
.talk-links a:hover { color: var(--accent); }
.talk-links a::before { content: "["; }
.talk-links a::after { content: "]"; }

.wip-card {
  border: 1px dashed var(--accent);
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  padding: 0.7rem 1.1rem;
  margin-top: 0.6rem;
}
.paper-card + .wip-card { border-top: 1px dashed var(--accent); }
/* hairline between the last paper card and the wip notice */
a.paper-card:last-of-type { border-bottom: 1px solid var(--hair); }
.wip-card .meta { color: var(--accent); margin-bottom: 0.35rem; font-size: 0.68rem; }
.wip-card h3 { font-size: 1.05rem; font-weight: 400; margin-bottom: 0.25rem; }
.wip-card .abstract { font-size: 0.88rem; }
/* talks notice sits inside the grid as one more talk card, but stays compact:
   pinned to the top of its cell at ~20% of the row height instead of stretching */
.talks-wip {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.8rem 1rem;
  align-self: start;
  min-height: min-content;
}
.talks-wip h3 { font-size: 0.85rem; margin-bottom: 0; }
.talks-wip .meta { margin-bottom: 0.25rem; }

/* ---------- article pages ---------- */

.article {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem 5rem;
}

.article-head { padding: 3rem 0 1.2rem; border-bottom: 1px solid var(--hair); margin-bottom: 1.8rem; }
.article-head p { margin-bottom: 0; }

.article-head h1 {
  font-weight: 420;
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin-bottom: 0.9rem;
}

.subtitle { font-size: 1.25rem; line-height: 1.45; color: var(--muted); font-style: italic; max-width: 30em; }

.meta { margin-top: 0.7rem; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.meta a { text-decoration: none; }

.meta-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-top: 0.8rem; }
.meta-row .meta { margin-top: 0; }
.meta-row .src-btn { margin-top: 0; }

.src-btn {
  display: inline-block;
  margin-top: 0.8rem;
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0.38rem 0.75rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.src-btn:hover { background: var(--accent); color: var(--bg); }

.toc {
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--hair);
  border-radius: 4px;
  padding: 1.1rem 1.3rem;
  margin: 0 0 2.6rem;
  line-height: 2;
}
.toc-title { letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.7rem; margin-bottom: 0.4rem; color: var(--accent); }
.toc a { text-decoration: none; display: block; }
.toc a:hover { color: var(--accent); }
.toc .toc-sub { padding-left: 1.2rem; }

.article h2 {
  font-weight: 480;
  font-size: 1.7rem;
  line-height: 1.25;
  margin: 3rem 0 1.1rem;
  letter-spacing: -0.01em;
}
.article h2 .no { color: var(--accent); font-style: italic; margin-right: 0.35em; font-weight: 400; }

.article h3 { font-weight: 500; font-size: 1.25rem; margin: 2.4rem 0 0.9rem; }

.article p { margin-bottom: 1.15rem; }
.article p strong { font-weight: 600; }

.article ul, .article ol { margin: 0 0 1.15rem 1.3rem; }
.article li { margin-bottom: 0.5rem; }
.article li > ul, .article li > ol { margin: 0.4rem 0 0.4rem 1.3rem; }

.article blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1.2rem;
  margin: 1.4rem 0;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--muted);
}
.article blockquote p:last-child { margin-bottom: 0; }

.figure { margin: 2rem 0 2.4rem; }
.figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}
.caption { margin-top: 0.6rem; font-size: 0.72rem; letter-spacing: 0.04em; color: var(--muted); line-height: 1.6; }
.caption::before { content: "◆ "; color: var(--accent); font-size: 0.6rem; }

pre {
  background: var(--code-bg);
  border: 1px solid var(--hair);
  border-radius: 4px;
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  margin: 1.4rem 0;
  font-size: 0.82rem;
  line-height: 1.7;
}
code { font-family: "Fragment Mono", ui-monospace, "SF Mono", Menlo, monospace; }
p code, li code {
  background: var(--code-bg);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  font-size: 0.82em;
}

/* syntax highlighting (Prism, build-time) */
:root {
  --tok-comment: #9a9184;
  --tok-keyword: #a626a4;
  --tok-string: #50a14f;
  --tok-number: #b76b01;
  --tok-function: #4078f2;
  --tok-type: #c18401;
}
[data-theme="dark"] {
  --tok-comment: #7f7668;
  --tok-keyword: #c678dd;
  --tok-string: #98c379;
  --tok-number: #d19a66;
  --tok-function: #61afef;
  --tok-type: #e5c07b;
}
pre .token.comment, pre .token.prolog, pre .token.doctype, pre .token.cdata { color: var(--tok-comment); font-style: italic; }
pre .token.keyword, pre .token.builtin, pre .token.important { color: var(--tok-keyword); }
pre .token.string, pre .token.char, pre .token.attr-value { color: var(--tok-string); }
pre .token.number, pre .token.boolean, pre .token.constant { color: var(--tok-number); }
pre .token.function { color: var(--tok-function); }
pre .token.class-name, pre .token.symbol, pre .token.namespace { color: var(--tok-type); }
pre .token.operator, pre .token.punctuation { opacity: 0.75; }

.article table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.6rem 0;
  font-size: 0.88rem;
  line-height: 1.55;
}
.article th, .article td {
  border: 1px solid var(--hair);
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.article th {
  font-family: "Fragment Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--code-bg);
}

.article .katex-display {
  margin: 1.5rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2rem 0;
}
.article .katex { font-size: 1.02em; }
/* keep a formula on one line inside table cells — the table scrolls instead of
   the math breaking mid-expression */
.article td .katex, .article th .katex { white-space: nowrap; }

hr.sep { border: none; border-top: 1px solid var(--hair); margin: 3rem 0; }

.backlink { font-family: "Fragment Mono", ui-monospace, monospace; font-size: 0.78rem; }
.backlink a { text-decoration: none; color: var(--muted); }
.backlink a:hover { color: var(--accent); }

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

footer { border-top: 1px solid var(--hair); }
.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.6rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.footer-inner a { text-decoration: none; color: var(--muted); }
.footer-inner a:hover { color: var(--accent); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.4rem; }
.footer-copy { text-align: center; }

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

@media (max-width: 640px) {
  body { font-size: 1.09rem; }
  .hero { padding: 3rem 0 2.2rem; }
  /* title: one phrase per line instead of dot-separated wrapping */
  .hero h1 { margin-left: -0.5rem; margin-right: -0.5rem; }
  .hero h1 .sep { display: none; }
  .hero h1 .seg { display: block; }
  nav { gap: 1rem; font-size: 0.72rem; }
  nav .hide-sm { display: none; }
  nav .only-sm { display: inline; }
  .figure img { padding: 0.5rem; }
  .article-head { padding: 2.8rem 0 1.8rem; }
}

/* markdown build: figures leave empty <p> wrappers behind */
.article p:empty { display: none; margin: 0; }
