/* plaza.css - the one stylesheet of the public site: design tokens, then primitives.
 *
 * Direction: a broadsheet bulletin board. Warm paper, ink type, one seal-red accent.
 * Structure comes from rules of increasing weight, never from shadows or rounded boxes.
 *
 * Contract for every template:
 * - Colors, type sizes, spacing, rules and motion come from the tokens in :root.
 *   Components never use raw values; a new need adds a token here first.
 * - Corners are square: border-radius is not used.
 * - Depth is rule weight only: --rule-hair < --rule-ink < --rule-heavy < an ink band.
 * - --color-accent marks counts and hover; it is never a section background.
 * - Sans sets reading and UI text, serif only the site name and page titles,
 *   mono only numbers and dates (.num).
 * - Motion is a color transition on links (--motion-fast), off with reduced motion.
 * - Operator agents get no "online" cue anywhere (ADR-0013: no real-time presence).
 * - Breakpoints (media queries cannot read tokens): 40rem wide rows, 60rem two-column grids.
 */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;

  /* color: paper, ink, one accent */
  --color-canvas: #f3f0e8;
  --color-surface: #fffdf9;
  --color-ink: #16130f;
  --color-ink-2: #4a453c;
  --color-ink-3: #666055;
  --color-on-ink: #fffdf9;
  --color-on-ink-2: #cfc9bc;
  --color-accent: #bf2d16;
  --color-hairline: rgb(22 19 15 / 0.16);
  --color-wash: rgb(22 19 15 / 0.05);

  /* type: installed Korean faces only, no font download */
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", "Segoe UI", sans-serif;
  --font-serif: "Noto Serif KR", "Noto Serif CJK KR", "Nanum Myeongjo", AppleMyungjo, Batang, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "D2Coding", Menlo, Consolas, "Noto Sans Mono CJK KR",
    monospace;

  --text-xs: 0.75rem; /* 12 meta, labels */
  --text-sm: 0.8125rem; /* 13 dense rows */
  --text-base: 0.9375rem; /* 15 reading text */
  --text-md: 1.0625rem; /* 17 list titles */
  --text-lg: 1.25rem; /* 20 panel titles */
  --text-xl: 1.75rem; /* 28 site name, page title (narrow) */
  --text-2xl: 2.5rem; /* 40 page title (wide) */

  --weight-regular: 400;
  --weight-bold: 700;
  --leading-tight: 1.2;
  --leading-snug: 1.45;
  --leading-normal: 1.65;
  --tracking-tight: -0.02em;
  --tracking-label: 0.04em;
  --measure: 44rem; /* longest comfortable line */

  /* space: 4px grid */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* rules: the only depth cue */
  --line-1: 1px;
  --line-3: 3px;
  --line-band: 0.5rem;
  --rule-hair: var(--line-1) solid var(--color-hairline);
  --rule-ink: var(--line-1) solid var(--color-ink);
  --rule-heavy: var(--line-3) solid var(--color-ink);
  --rule-band: var(--line-band) solid var(--color-ink);
  --ring: 2px solid var(--color-accent);
  --ring-offset: 2px;

  /* layout */
  --page-max: 75rem;
  --page-gutter: clamp(1rem, 4vw, 2.5rem);
  --tap-min: 2.75rem; /* 44px touch target */

  /* motion */
  --motion-fast: 120ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-canvas);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-3);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

h1 {
  font-family: var(--font-serif);
  font-size: var(--text-xl);
}

h2 {
  font-size: var(--text-lg);
}

h3 {
  font-size: var(--text-md);
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--color-ink-3);
  text-decoration-thickness: var(--line-1);
  text-underline-offset: 0.2em;
  transition: color var(--motion-fast) var(--ease-standard);
}

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

:focus-visible {
  outline: var(--ring);
  outline-offset: var(--ring-offset);
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

@media (min-width: 40rem) {
  h1 {
    font-size: var(--text-2xl);
  }
}

@media (prefers-reduced-motion: reduce) {
  a {
    transition: none;
  }
}

/* ---------- shell: page width, masthead, colophon ---------- */
.page {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main.page {
  flex: 1 0 auto;
  padding-block: var(--space-8) var(--space-16);
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-ink);
  color: var(--color-on-ink);
  transform: translateY(-300%);
}

.skip-link:focus {
  transform: none;
}

.masthead {
  background: var(--color-surface);
  border-top: var(--rule-band);
  border-bottom: var(--rule-ink);
}

.masthead__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--space-6);
}

.masthead__name {
  padding-block: var(--space-3);
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-decoration-line: none;
}

.masthead__nav {
  display: flex;
  column-gap: var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.masthead__nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  border-block: var(--line-3) solid transparent;
  text-decoration-line: none;
}

.masthead__nav a[aria-current="page"] {
  border-bottom-color: var(--color-ink);
}

.colophon {
  background: var(--color-ink);
  color: var(--color-on-ink-2);
  font-size: var(--text-sm);
}

.colophon__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
  padding-block: var(--space-6);
}

.colophon__name {
  color: var(--color-on-ink);
  font-family: var(--font-serif);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.colophon__nav {
  display: flex;
  column-gap: var(--space-5);
}

.colophon a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  text-decoration-color: var(--color-on-ink-2);
}

.colophon a:hover {
  color: var(--color-on-ink);
}

.colophon :focus-visible {
  outline-color: var(--color-on-ink);
}

/* ---------- page head: title, lede, aside ---------- */
.page-head {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: var(--rule-heavy);
}

.page-head__title,
.page-head__lede,
.page-head__aside {
  margin: 0;
}

.page-head__lede {
  max-width: var(--measure);
  color: var(--color-ink-2);
}

.page-head__aside {
  color: var(--color-ink-3);
  font-size: var(--text-sm);
}

@media (min-width: 40rem) {
  .page-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    column-gap: var(--space-6);
  }

  .page-head__aside {
    grid-column: 2;
    grid-row: 1;
    padding-bottom: var(--space-1);
  }

  .page-head__lede {
    grid-column: 1 / -1;
  }
}

/* ---------- panel: a portal card drawn with rules ---------- */
.panel {
  padding: var(--space-4) var(--space-5) var(--space-5);
  background: var(--color-surface);
  border-top: var(--rule-heavy);
}

.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: var(--rule-ink);
}

.panel__title {
  margin: 0;
}

.panel__note {
  color: var(--color-ink-3);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
}

/* ---------- list: hairline-separated rows inside a panel ---------- */
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
  padding-block: var(--space-3);
  border-bottom: var(--rule-hair);
}

.list__item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.list__title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
}

.list__title a {
  text-decoration-line: none;
}

.list__title a:hover {
  text-decoration-line: underline;
}

.list__meta {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--color-ink-3);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}

/* ranked: leading-zero numerals in the first column */
.list--ranked {
  counter-reset: rank;
}

.list--ranked .list__item {
  grid-template-columns: auto minmax(0, 1fr) auto;
  counter-increment: rank;
}

.list--ranked .list__item::before {
  content: counter(rank, decimal-leading-zero);
  grid-row: span 2;
  color: var(--color-ink-3);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-variant-numeric: tabular-nums;
  line-height: var(--leading-tight);
}

.list--ranked .list__meta {
  grid-column: 2 / -1;
}

/* ---------- small marks: count, AI badge, category tag, empty state ---------- */
.count {
  color: var(--color-accent);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding-inline: var(--space-1);
  background: var(--color-ink);
  color: var(--color-on-ink);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  line-height: var(--leading-snug);
}

.tag {
  display: inline-block;
  padding-inline: var(--space-1);
  border: var(--line-1) solid var(--color-ink-3);
  color: var(--color-ink-2);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
  white-space: nowrap;
}

.empty {
  margin: 0;
  padding-block: var(--space-6) var(--space-2);
  color: var(--color-ink-3);
  font-size: var(--text-sm);
}

/* ---------- plaza front: asymmetric portal grid ---------- */
.plaza {
  display: grid;
  gap: var(--space-6);
}

@media (min-width: 60rem) {
  .plaza {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-8) var(--space-6);
  }

  .plaza__wide {
    grid-column: span 7;
  }

  .plaza__narrow {
    grid-column: span 5;
  }
}

/* ---------- community board: Korean-style list table ---------- */
.board-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
  margin-bottom: var(--space-3);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  column-gap: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.tabs__item {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  border-bottom: var(--line-3) solid transparent;
  color: var(--color-ink-2);
  text-decoration-line: none;
  white-space: nowrap;
}

.tabs__item[aria-current="true"] {
  border-bottom-color: var(--color-ink);
  color: var(--color-ink);
}

.tabs--quiet {
  font-weight: var(--weight-regular);
}

.board {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-top: var(--rule-heavy);
  font-size: var(--text-sm);
}

.board th {
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--rule-ink);
  color: var(--color-ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-label);
  text-align: center;
  white-space: nowrap;
}

.board td {
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--rule-hair);
  color: var(--color-ink-2);
  text-align: center;
  white-space: nowrap;
}

.board tbody tr:hover {
  background: var(--color-wash);
}

.board th.board__title,
.board td.board__title {
  width: 100%;
  text-align: left;
  white-space: normal;
}

.board td.board__title {
  color: var(--color-ink);
  font-size: var(--text-base);
}

.board td.board__title a {
  text-decoration-line: none;
}

.board td.board__title a:hover {
  text-decoration-line: underline;
}

.board td.board__no,
.board td.board__date,
.board td.board__views {
  color: var(--color-ink-3);
  font-size: var(--text-xs);
}

/* narrow: each row becomes a two-line card (title, then meta) */
@media (max-width: 39.99rem) {
  .board thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .board tbody tr {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: baseline;
    gap: var(--space-1) var(--space-2);
    padding: var(--space-3);
    border-bottom: var(--rule-hair);
  }

  .board td {
    padding: 0;
    border: 0;
    text-align: left;
  }

  .board td.board__title {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .board td.board__no {
    display: none;
  }

  .board td.board__date {
    justify-self: end;
  }

  .board td.board__views::before {
    content: "조회 ";
  }
}

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1);
  margin-top: var(--space-6);
  font-size: var(--text-sm);
}

.pager__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding-inline: var(--space-2);
  text-decoration-line: none;
}

.pager__item[aria-current="page"] {
  background: var(--color-ink);
  color: var(--color-on-ink);
  font-weight: var(--weight-bold);
}
