/* Technical journal system — tokens from design/stitch/DESIGN.md.
   Cobalt (--primary) is reserved for the active section and for links. */
:root {
  --bg: #F7F8FA;
  --bg-bright: #FFFFFF;
  --surface-low: #F0F2F7;
  --surface: #E8ECF4;
  --ink: #151922;
  --ink-2: #434751;
  --line: #DFE2EF;
  --primary: #3155E7;
  --error: #B91C1C;
  --on-error: #FFFFFF;
  --error-c: #FFDAD6;
  --on-error-c: #93000B;
  --warn-c: #FFDDB8;
  --on-warn-c: #2A1700;

  /* Pretendard sets Hangul and Latin to one rhythm, which mixed Korean summaries
     under English titles need; headings use it too (Archivo had no Hangul). */
  --font-body: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --font-display: var(--font-body);
  --font-mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, monospace;

  --fast: 100ms ease-out;
  --topbar-h: 48px;
}

/* Light is the default, as in the mock-up; the top-bar toggle sets data-theme="dark"
   on <html> (saved in localStorage, applied before first paint in index.html). */
:root { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151922;
  --bg-bright: #2C303A;
  --surface-low: #181C25;
  --surface: #1E222D;
  --ink: #F7F8FA;
  --ink-2: #C3C6D3;
  --line: #2C303A;
  --primary: #B9C3FF;
  --error: #FFB4AB;
  --on-error: #690005;
  --error-c: #93000B;
  --on-error-c: #FFDAD6;
  --warn-c: #653E00;
  --on-warn-c: #FFDDB8;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all; /* break Korean between words, not inside them */
}

::selection { background: #DDE1FF; color: #001257; }

a { color: var(--primary); text-underline-offset: 4px; text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* .mono = aligned digits in the body face (safe for Korean labels);
   .code = the monospace face, only for digits and identifiers (it has no Hangul). */
.mono { font-variant-numeric: tabular-nums; }
.code { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.icon { width: 16px; height: 16px; flex: none; }
[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1160px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.brand:hover { text-decoration: none; }
.brand-h1 { font: inherit; } /* the site name is the page's h1; it keeps the brand look */
.logo { flex: none; }
.logo-ink { fill: var(--ink); }
.logo-paper { fill: var(--bg); }
.logo-line { stroke: var(--bg); }
.topbar-meta { display: flex; align-items: center; gap: 20px; min-width: 0; }
.topbar-updated { font-size: 12px; line-height: 16px; color: var(--ink-2); white-space: nowrap; }
.topbar-sep { color: var(--line); }
.theme-btn {
  display: inline-flex;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: color var(--fast), background-color var(--fast);
}
.theme-btn:hover { color: var(--ink); background: var(--surface-low); }
.theme-btn .icon-sun { display: none; }
:root[data-theme="dark"] .theme-btn .icon-sun { display: block; }
:root[data-theme="dark"] .theme-btn .icon-moon { display: none; }
.bm-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  white-space: nowrap;
}
.bm-link .mono { font-size: 12px; }

/* mobile section menu */
.mnav { display: none; }

/* layout */
.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 24px 0;
  display: grid;
  grid-template-columns: 200px minmax(0, 740px);
  gap: 64px;
  align-items: start;
}

.sidebar { position: sticky; top: calc(var(--topbar-h) + 32px); padding-top: 4px; }
.nav-label {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.nav-list { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.nav-list li + li { margin-top: 4px; }
.nav-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-left: -1px;
  padding: 6px 0 6px 14px;
  border-left: 2px solid transparent;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 20px;
  transition: color var(--fast);
}
.nav-list a:hover { color: var(--ink); text-decoration: none; }
.nav-list a[aria-current="true"] { border-left-color: var(--primary); color: var(--primary); font-weight: 600; }
.nav-n { font-size: 12px; line-height: 16px; color: var(--ink-2); font-weight: 400; }

.shortcuts {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-2);
}
.shortcuts p { margin: 0 0 6px; }
.shortcuts kbd { font-family: inherit; color: var(--ink); }

main {
  min-width: 0;
  padding-bottom: 80px;
  /* Digest text carries long unbroken tokens (config keys, URLs, "A·B·C" lists);
     without this they set the column's min width and the page scrolls sideways on phones. */
  overflow-wrap: anywhere;
}
.section { scroll-margin-top: calc(var(--topbar-h) + 32px); }
.section + .section { margin-top: 64px; }

/* section headings */
h1, h2, h3 { margin: 0; }
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 16px;
}
.section-head-rule { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.section-head h2 {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 32px;
  font-weight: 700;
  letter-spacing: -0.25px;
}
.section-note { font-size: 12px; line-height: 16px; color: var(--ink-2); }
.news-updated { display: none; }
.section-intro { margin: 12px 0 0; color: var(--ink-2); font-size: 13px; line-height: 20px; }

/* digest header */
.dateline { margin: 0 0 8px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-2); }
.digest-titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 16px;
}
.digest-titlebar h2 {
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.digest-times { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 12px; line-height: 16px; color: var(--ink-2); }
.digest-times span:empty { display: none; }
.digest-times span + span::before { content: "·"; margin-right: 12px; color: var(--line); }
.digest-summary { margin: 0 0 32px; max-width: 68ch; font-size: 16px; line-height: 26px; color: var(--ink-2); }

/* entry list: digest, news, security, archive, bookmarks share one row style */
.entry-list { margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--line); }
#digest-body .entry-list { border-top: 1px solid var(--line); }
.entry { padding: 20px 0; scroll-margin-top: calc(var(--topbar-h) + 24px); }
.entry + .entry { border-top: 1px solid var(--line); }
.entry-lead { padding: 24px 0; }
.entry-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.entry-main { min-width: 0; flex: 1; }
.entry-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--ink-2);
}
.entry-meta .mono, .entry-meta .code { font-weight: 400; letter-spacing: 0; }
.entry-cat { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.entry-cat::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cat, var(--line));
}
/* category hues from the previous design; Kotlin, Go and TypeScript are nudged off
   AI, DataScience and Python, which their brand colours would otherwise sit on */
.cat-Java { --cat: #e76f00; }
.cat-Kotlin { --cat: #6a2ee8; }
.cat-Spring { --cat: #6db33f; }
.cat-Node { --cat: #3d7a2f; }
.cat-Go { --cat: #0098bd; }
.cat-Rust { --cat: #c0392b; }
.cat-TypeScript { --cat: #1d4ed8; }
.cat-AI { --cat: #7c3aed; }
.cat-Agents { --cat: #0d9488; }
.cat-LLM { --cat: #db2777; }
.cat-Architecture { --cat: #64748b; }
.cat-Python { --cat: #3776ab; }
.cat-DataScience { --cat: #06b6d4; }
.entry-title { font-size: 16px; line-height: 1.45; font-weight: 600; letter-spacing: -0.1px; margin-bottom: 6px; }
.entry-lead .entry-title { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; margin-bottom: 8px; }
.entry-summary { margin: 0; font-size: 14px; line-height: 22px; color: var(--ink-2); }
.entry-lead .entry-summary { color: var(--ink); margin-bottom: 12px; }

.entry-detail > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: -8px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background-color var(--fast);
}
.entry-detail > summary::-webkit-details-marker { display: none; }
.entry-detail > summary:hover { background: var(--surface-low); }
.chevron { width: 14px; height: 14px; transition: transform 180ms cubic-bezier(0.2, 0, 0, 1); }
.entry-detail[open] .chevron { transform: rotate(180deg); }
.entry-detail-body {
  margin-top: 12px;
  padding-left: 16px;
  border-left: 2px solid var(--line);
  white-space: pre-line;
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-2);
}

/* bookmark toggle */
.bm-btn {
  flex: none;
  margin-top: 2px;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  line-height: 0;
  cursor: pointer;
  transition: color var(--fast), background-color var(--fast);
}
.bm-btn:hover { color: var(--ink); background: var(--surface-low); }
.bm-btn svg { fill: none; }
.bm-btn[aria-pressed="true"] { color: var(--primary); }
.bm-btn[aria-pressed="true"] svg { fill: currentColor; }
.entry-actions { display: flex; gap: 16px; margin-top: 4px; font-size: 12px; line-height: 16px; font-weight: 500; }
.text-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink-2);
  cursor: pointer;
}
.text-btn:hover { color: var(--ink); }

/* toolbars, chips, search */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.toolbar-stack { display: grid; justify-content: stretch; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  padding: 4px 10px;
  border: 0;
  border-radius: 6px;
  background: var(--surface-low);
  color: var(--ink-2);
  font: 500 12px/16px var(--font-body);
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: color var(--fast), background-color var(--fast);
}
.filter:hover { color: var(--ink); }
.filter.on { background: var(--ink); color: var(--bg); }
.filter-n { margin-left: 4px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; opacity: 0.75; }
.filter.on .filter-n { opacity: 1; }

.sec-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.sec-toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }

.search-wrap { position: relative; flex: 1 1 auto; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-2); pointer-events: none; }
.search {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-low);
  color: var(--ink);
  font: 400 14px/22px var(--font-body);
}
.search::placeholder { color: var(--ink-2); }
.search:focus { outline: none; border-color: var(--ink); }
.search:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; }
.search-note { margin: 12px 0 0; font-size: 12px; line-height: 16px; color: var(--ink-2); }

.more {
  display: block;
  margin-top: 16px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: 500 14px/20px var(--font-body);
  cursor: pointer;
  transition: background-color var(--fast);
}
.more:hover { background: var(--surface-low); }

/* security severity */
.sev {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0;
}
.sev-critical { background: var(--error); color: var(--on-error); }
.sev-high { background: var(--error-c); color: var(--on-error-c); }
.sev-medium { background: var(--warn-c); color: var(--on-warn-c); }
.sev-low, .sev-none { background: var(--surface); color: var(--ink-2); font-weight: 500; }
.sec-id { color: var(--ink); }

/* archive */
.archive-days { border-bottom: 1px solid var(--line); }
.archive-day { padding: 16px 0; }
.archive-day + .archive-day { border-top: 1px solid var(--line); }
.archive-day > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.archive-day > summary::-webkit-details-marker { display: none; }
.archive-day-head { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.archive-date { flex: none; font-size: 13px; line-height: 18px; font-weight: 600; }
.archive-summary { font-size: 13px; line-height: 20px; color: var(--ink-2); }
/* a closed day shows two lines of its summary; opening it shows the rest */
.archive-day:not([open]) .archive-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.archive-count { flex: none; font-size: 12px; line-height: 16px; color: var(--ink-2); }
.archive-day > .entry-list { margin-top: 12px; padding-left: 16px; border-left: 1px solid var(--line); border-bottom: 0; }
.archive-day .entry { padding: 14px 0; }

/* sources */
#sources-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px 32px;
  padding-top: 24px;
}
.source-cat h3 { margin-bottom: 8px; font-size: 13px; line-height: 18px; font-weight: 600; }
.source-count { margin-left: 6px; font-weight: 400; color: var(--ink-2); }
.source-links { margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 20px; }
.source-links li + li { margin-top: 4px; }

/* empty states */
.empty { margin: 0; padding: 24px 0; color: var(--ink-2); }
.empty-state { padding: 40px 0; border-bottom: 1px solid var(--line); text-align: center; }
.empty-state p { margin: 0 0 8px; }
.empty-title { font-size: 16px; line-height: 24px; font-weight: 600; }
.empty-desc { font-size: 13px; line-height: 20px; color: var(--ink-2); }
.empty-state a { font-weight: 500; }

.site-footer {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 16px;
  color: var(--ink-2);
  text-align: center;
}

/* tablet */
@media (max-width: 960px) {
  .layout { grid-template-columns: 180px minmax(0, 1fr); gap: 40px; }
  #sources-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* mobile: brand bar scrolls away, a one-line section menu sticks instead */
@media (max-width: 720px) {
  :root { --topbar-h: 44px; } /* height of .mnav, the bar that sticks on phones */
  .topbar { position: static; }
  .topbar-inner { padding: 0 16px; }
  .topbar-updated, .topbar-sep { display: none; } /* the time moves to the news note */
  .news-updated { display: inline; }

  .mnav {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    gap: 20px;
    padding: 0 16px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .mnav::-webkit-scrollbar { display: none; }
  .mnav a {
    flex: none;
    padding: 10px 0;
    border-bottom: 2px solid transparent;
    color: var(--ink-2);
    font-size: 14px;
    line-height: 20px;
  }
  .mnav a:hover { text-decoration: none; color: var(--ink); }
  .mnav a[aria-current="true"] { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }

  .layout { display: block; padding: 24px 16px 0; }
  .sidebar { display: none; }
  main { padding-bottom: 64px; }
  .section + .section { margin-top: 48px; }

  .dateline { margin-bottom: 6px; font-weight: 600; color: var(--ink); }
  .digest-titlebar { justify-content: flex-start; gap: 4px 12px; margin-bottom: 12px; }
  .digest-titlebar h2 { font-size: 28px; line-height: 36px; letter-spacing: -0.25px; }
  .digest-summary { margin-bottom: 24px; font-size: 14px; line-height: 22px; }
  .entry-row { gap: 12px; }
  .entry-lead { padding: 20px 0; }

  .archive-day-head { flex-direction: column; gap: 2px; }
  #sources-list { grid-template-columns: 1fr; gap: 20px; }
}
