@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,500&family=Gowun+Batang:wght@400;700&display=swap');

/* ============================================================
   상자 속의 우주 · Cosmos in the Box
   Shared design system
   ============================================================ */

:root {
  /* monochrome, neutral grayscale, no color tint. The only "accent" is near-white. */
  --bg:        #0b0b0d;
  --bg-soft:   #121214;
  --panel:     #17171a;
  --panel-2:   #212125;
  --line:      #2e2e33;
  --ink:       #ededf0;
  --ink-dim:   #9a9aa3;
  --ink-faint: #62626b;
  --accent:    #ededf0;   /* near-white, the single accent in a monochrome scheme */
  --accent-2:  #b8b8c0;
  --accent-3:  #cfcfd6;
  --warn:      #b8b8c0;
  --hot:       #e0e0e6;
  --radius:    9px;
  --radius-sm: 6px;
  --shadow:    0 18px 44px rgba(0,0,0,.55);
  --maxw:      1080px;
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --display: "Fraunces", "Gowun Batang", "Iowan Old Style", "Palatino Linotype",
             Palatino, "Nanum Myeongjo", Georgia, serif;   /* refined editorial serif (Latin + Korean) */
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "D2Coding", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 820px at 50% -12%, rgba(224,160,58,.055), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* very faint neutral star dust, a hint of night sky, not a glowy AI cosmos */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 40px 60px, rgba(236,230,218,.5), transparent),
    radial-gradient(1px 1px at 200px 140px, rgba(236,230,218,.35), transparent),
    radial-gradient(1px 1px at 320px 260px, rgba(236,230,218,.4), transparent),
    radial-gradient(1px 1px at 120px 300px, rgba(236,230,218,.3), transparent);
  background-repeat: repeat;
  background-size: 420px 380px;
  opacity: .35;
}
/* decorative cosmos layer (nebulae, spiral galaxies, box-with-?) injected by site.js */
.cosmos-bg {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: -1; pointer-events: none; opacity: .45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
/* Centered within the content column (to the right of the sidebar), wider than before. */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 40px; }

/* language visibility */
html.lang-en .i18n-ko { display: none !important; }
html:not(.lang-en) .i18n-en { display: none !important; }

/* ---------- Left sidebar nav ---------- */
:root { --side: 252px; }
body { padding-left: var(--side); }

.sidebar {
  position: fixed; top: 0; left: 0; width: var(--side); height: 100vh;
  overflow-y: auto; z-index: 50;
  background: linear-gradient(180deg, var(--bg-soft), var(--bg));
  border-right: 1px solid var(--line);
  padding: 22px 14px 18px; display: flex; flex-direction: column;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--display); font-weight: 600; letter-spacing: -.01em; color: var(--ink);
  font-size: 1.25rem; padding: 4px 8px 12px; font-optical-sizing: auto;
}
.sidebar .brand-tag {
  font-family: var(--font); font-size: .72rem; line-height: 1.55;
  color: var(--ink-dim); letter-spacing: 0; padding: 0 6px 12px; max-width: 220px;
}
.sidebar .brand:hover { text-decoration: none; }
/* logo mark: a little box holding a cosmos (stars glowing inside) */
.brand .dot {
  width: 20px; height: 20px; border-radius: 6px; flex: none;
  background:
    radial-gradient(1px 1px at 62% 34%, #fff, transparent),
    radial-gradient(1px 1px at 34% 62%, rgba(236,236,240,.85), transparent),
    radial-gradient(1.4px 1.4px at 70% 72%, rgba(236,236,240,.7), transparent),
    radial-gradient(circle at 40% 30%, rgba(255,255,255,.14), transparent 70%),
    linear-gradient(145deg, var(--panel-2), #050506);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 8px rgba(255,255,255,.10);
}

.side-home {
  display: flex; align-items: center; gap: 8px;
  color: var(--ink-dim); font-weight: 700; font-size: .9rem;
  padding: 8px 10px; border-radius: 9px;
}
.side-home:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
.side-home.active { background: var(--panel); color: var(--ink); }

/* inline search box, filters the tree live as you type */
.nav-search {
  display: flex; align-items: center; gap: 7px; width: 100%;
  margin: 6px 0; padding: 7px 10px;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s;
}
.nav-search:focus-within { border-color: var(--accent); }
.nav-search .ns-ico { font-size: .8rem; opacity: .7; flex: none; }
.nav-search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  color: var(--ink); font: 500 .86rem var(--font);
}
.nav-search input::placeholder { color: var(--ink-faint); }
.nav-search input::-webkit-search-cancel-button { display: none; }
.nav-search .ns-clear { cursor: pointer; color: var(--ink-faint); font-size: .78rem; flex: none; }
.nav-search .ns-clear:hover { color: var(--ink); }
.nf-hide { display: none !important; }

.side-nav { display: flex; flex-direction: column; gap: 1px; }

/* category, collapsible <details>, styled as a clear section header */
.side-cat-group { margin-top: 6px; border-top: 1px solid var(--line); }
.side-cat-group:first-of-type { border-top: none; }
.side-cat-group > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  font-size: .86rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); padding: 16px 10px 8px;
}
.side-cat-group > summary .cat-ico { font-size: 1.1rem; }
.side-cat-group > summary::-webkit-details-marker { display: none; }
.side-cat-group > summary:hover { color: var(--ink); }
.side-cat .cat-ico { color: var(--cat); font-size: 1rem; }
.side-cat .sc-label { flex: 1; }
.cat-count, .t-count {
  font: 700 .66rem/1 var(--mono); color: var(--ink-faint);
  background: var(--panel); border-radius: 999px; padding: 3px 7px;
}
.side-cat-group[open] > summary .cat-ico { text-shadow: 0 0 10px var(--cat); }

/* topic, collapsible <details> */
.side-topic { margin-left: 4px; }
.side-topic > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 700; color: var(--ink-dim);
  padding: 6px 10px; border-radius: 8px;
}
.side-topic > summary::-webkit-details-marker { display: none; }
.side-topic > summary::before {
  content: "▸"; font-size: .62rem; color: var(--ink-faint); transition: transform .15s;
}
.side-topic[open] > summary::before { transform: rotate(90deg); }
.side-topic > summary:hover { background: var(--panel); color: var(--ink); }
.side-topic .t-count { margin-left: auto; }

/* concept link */
.side-item {
  display: block; margin-left: 15px; padding: 5px 8px 5px 13px;
  border-left: 1px solid var(--line);
  color: var(--ink-dim); font-size: .8rem;
}
.side-item:hover { color: var(--ink); border-left-color: var(--ink-faint); text-decoration: none; }
.side-item.active { color: var(--ink); font-weight: 600; background: var(--panel); border-left-color: var(--ink-dim); }

.side-tail { margin-top: auto; padding-top: 10px; }
.lang-switch { display: inline-flex; padding: 6px 10px 0; }
.lang-switch button {
  font: 700 .68rem/1 var(--font); letter-spacing: .05em;
  color: var(--ink-faint); background: transparent; border: 1px solid var(--line);
  padding: 4px 9px; cursor: pointer; transition: color .15s, background .15s;
}
.lang-switch button:first-child { border-radius: 6px 0 0 6px; }
.lang-switch button:last-child { border-radius: 0 6px 6px 0; border-left: none; }
.lang-switch button.on { color: var(--ink); background: var(--panel-2); }
.lang-switch button:not(.on):hover { color: var(--ink-dim); }

.side-foot {
  padding: 12px 10px 2px; font-size: .74rem;
  color: var(--ink-faint); line-height: 1.55;
}

/* mobile: sidebar becomes a top block (tree stays collapsible) */
@media (max-width: 860px) {
  body { padding-left: 0; }
  .sidebar {
    position: static; width: auto; height: auto;
    border-right: none; border-bottom: 1px solid var(--line); padding: 14px 18px;
  }
  .side-foot { display: none; }
}

/* landing category sections */
.cat-head {
  display: flex; align-items: center; gap: 12px; margin: 46px 0 4px;
}
.cat-head .cat-emblem {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  font-size: 1.3rem; border: 1px solid var(--line); background: var(--panel);
}
.cat-head h2 { font-family: var(--display); font-weight: 600; font-size: 1.7rem; margin: 0; letter-spacing: 0; }
.cat-head .cat-sub { color: var(--ink-faint); font-size: .9rem; }

/* ---------- Hero ---------- */
/* vertical-only padding so the shared .wrap horizontal padding (40px) is preserved
   and the title lines up with the body content */
.hero { padding-top: 76px; padding-bottom: 40px; text-align: center; }
.hero .kicker {
  display: inline-block; font-size: .8rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 18px;
  padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel);
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(2.6rem, 6.2vw, 4.4rem); line-height: 1.02;
  margin: 0 0 18px; font-weight: 600; letter-spacing: -.022em; color: var(--ink);
  font-optical-sizing: auto;
}
.hero p.lead {
  font-size: clamp(1rem, 2.2vw, 1.22rem); color: var(--ink-dim);
  max-width: 640px; margin: 0 auto;
}

/* ---------- Card grid ---------- */
.grid {
  display: grid; gap: 20px; padding: 20px 0 10px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
#sections { padding-bottom: 70px; }
.card {
  position: relative; display: block; overflow: hidden;
  background: linear-gradient(160deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; transition: transform .25s ease, border-color .25s ease, box-shadow .25s;
  color: var(--ink);
}
.card:hover {
  transform: translateY(-4px); border-color: var(--accent);
  box-shadow: var(--shadow); text-decoration: none;
}
.card .visual {
  position: relative;
  height: 128px; border-radius: var(--radius-sm); margin-bottom: 18px;
  border: 1px solid var(--line); overflow: hidden; background: #05070e;
}
.card .visual canvas { display: block; width: 100%; height: 100%; }
/* lid: a light seam that brightens on hover, as if the box is opening */
.card .visual::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05); transition: box-shadow .3s;
}
.card:hover .visual::before {
  box-shadow: inset 0 3px 18px rgba(255,255,255,.16), inset 0 1px 0 rgba(255,255,255,.3);
}
/* the whole card is a box: corner brackets on its frame that light up on hover */
.card::after {
  content: ""; position: absolute; inset: 9px; z-index: 2; pointer-events: none;
  --c: rgba(236,236,240,.18); --s: 17px; --t: 2px; transition: opacity .25s;
  background:
    linear-gradient(var(--c),var(--c)) top left    / var(--s) var(--t) no-repeat,
    linear-gradient(var(--c),var(--c)) top left    / var(--t) var(--s) no-repeat,
    linear-gradient(var(--c),var(--c)) top right    / var(--s) var(--t) no-repeat,
    linear-gradient(var(--c),var(--c)) top right    / var(--t) var(--s) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom left  / var(--s) var(--t) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom left  / var(--t) var(--s) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom right / var(--s) var(--t) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom right / var(--t) var(--s) no-repeat;
}
.card:hover::after { --c: var(--accent); }
.card .tag {
  font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent-2);
}
.card h3 { margin: 6px 0 8px; font-size: 1.28rem; letter-spacing: -.02em; }
.card p { margin: 0; color: var(--ink-dim); font-size: .94rem; }
.card .go {
  margin-top: 16px; font-size: .86rem; font-weight: 700; color: var(--accent);
  display: inline-flex; align-items: center; gap: 6px;
}

/* ---------- Article / concept page ---------- */
.concept-hero { padding-top: 60px; padding-bottom: 24px; }
.concept-hero .eyebrow {
  font-size: .82rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--accent);
}
.concept-hero h1 {
  font-family: var(--display);
  font-size: clamp(2.2rem, 5.2vw, 3.4rem); margin: 12px 0 14px;
  letter-spacing: -.02em; font-weight: 600; line-height: 1.08;
  font-optical-sizing: auto;
}
.concept-hero .lead { font-size: 1.15rem; color: var(--ink-dim); max-width: none; }
.meta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.chip {
  font-size: .8rem; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-dim);
}

.section { padding: 26px 0; }
.section h2 {
  font-family: var(--display); font-weight: 600;
  font-size: 1.55rem; letter-spacing: -.01em; margin: 8px 0 14px;
  font-optical-sizing: auto;
  display: flex; align-items: center; gap: 10px;
}
.section h2::before {
  content: ""; width: 3px; height: 20px; border-radius: 2px;
  background: var(--ink-dim);
}
.prose p { color: var(--ink-dim); font-size: 1.02rem; }
.prose strong { color: var(--ink); }
.prose .big-eq {
  text-align: center; font-family: var(--mono); font-size: 1.6rem;
  color: var(--ink); padding: 22px; margin: 18px 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.callout {
  border-left: 3px solid var(--accent); background: var(--panel);
  padding: 14px 18px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 18px 0; color: var(--ink-dim);
}
.callout strong { color: var(--accent); }

/* ---------- Simulation lab ---------- */
.lab {
  position: relative;
  background: linear-gradient(160deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line); border-top: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin: 20px 0;
  box-shadow: var(--shadow);
}
.lab-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.lab-head h3 { margin: 0; font-size: 1.1rem; }
.lab-head .hint { font-size: .84rem; color: var(--ink-faint); }
.stage {
  position: relative; width: 100%; border-radius: var(--radius-sm);
  overflow: hidden; background: #060608; border: 1px solid var(--line);
  box-shadow: inset 0 0 60px rgba(255,255,255,.03);
}
.stage canvas { display: block; width: 100%; }
/* corner brackets, each simulation reads as a cosmos framed inside a box/viewport */
.stage::after {
  content: ""; position: absolute; inset: 7px; pointer-events: none; z-index: 3;
  --c: rgba(236,236,240,.32); --s: 15px; --t: 2px;
  background:
    linear-gradient(var(--c),var(--c)) top left    / var(--s) var(--t) no-repeat,
    linear-gradient(var(--c),var(--c)) top left    / var(--t) var(--s) no-repeat,
    linear-gradient(var(--c),var(--c)) top right    / var(--s) var(--t) no-repeat,
    linear-gradient(var(--c),var(--c)) top right    / var(--t) var(--s) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom left  / var(--s) var(--t) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom left  / var(--t) var(--s) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom right / var(--s) var(--t) no-repeat,
    linear-gradient(var(--c),var(--c)) bottom right / var(--t) var(--s) no-repeat;
}

.controls {
  display: grid; gap: 16px; margin-top: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.ctrl { display: flex; flex-direction: column; gap: 6px; }
.ctrl label {
  font-size: .82rem; font-weight: 600; color: var(--ink-dim);
  display: flex; justify-content: space-between; gap: 8px;
}
.ctrl label .val { color: var(--accent); font-family: var(--mono); font-weight: 700; }
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px;
  background: var(--panel-2); outline: none; cursor: pointer;
}
/* number/text input for controls (e.g. Collatz start) */
.num-input {
  width: 100%; padding: 8px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--ink);
  font: 600 .95rem var(--mono);
}
.num-input:focus { outline: none; border-color: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, var(--accent));
  box-shadow: 0 0 10px var(--accent); cursor: pointer; border: none;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: none;
  background: var(--accent); box-shadow: 0 0 10px var(--accent); cursor: pointer;
}

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  font-family: var(--font); font-size: .9rem; font-weight: 700;
  padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: #fff; }
.btn.primary {
  background: var(--accent);
  border-color: transparent; color: #17171a;
}
.btn.primary:hover { filter: brightness(1.06); }
.toggle-group { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.toggle-group button {
  background: var(--panel); color: var(--ink-dim); border: none; cursor: pointer;
  padding: 9px 14px; font-family: var(--font); font-weight: 700; font-size: .86rem;
}
.toggle-group button.on { background: var(--accent); color: #17171a; }

.readout {
  display: grid; gap: 10px; margin-top: 16px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.stat {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.stat .k { font-size: .74rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 1.3rem; font-weight: 800; font-family: var(--mono); color: var(--ink); margin-top: 2px; }

/* ---------- Prev/next + footer ---------- */
.pager { display: flex; justify-content: space-between; gap: 12px; padding: 40px 0; flex-wrap: wrap; }
.pager a {
  flex: 1 1 220px; padding: 16px 18px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); color: var(--ink);
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .dir { font-size: .76rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .08em; }
.pager .ttl { font-weight: 700; margin-top: 4px; }
.pager .next { text-align: right; }

footer {
  border-top: 1px solid var(--line); padding: 30px 0 50px;
  color: var(--ink-faint); font-size: .86rem; text-align: center;
}

/* ---------- Utility ---------- */
.center { text-align: center; }
.muted { color: var(--ink-faint); }
.pill-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .84rem; color: var(--ink-dim); margin-top: 12px; }
.pill-legend span { display: inline-flex; align-items: center; gap: 6px; }
.pill-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

@media (max-width: 640px) {
  .hero { padding: 50px 0 24px; }
  .controls { grid-template-columns: 1fr 1fr; }
}
