/* ===================================================================
   프린키피아 · Principia — AI와 함께 고전 속으로 시리즈
   톤: 감청색(밤하늘) + 금색(고서 장정). Part 6(원전 이후)만 보라 톤으로 구분.
=================================================================== */

:root {
  --bg: #0a0f1f;
  --bg-elevated: #10192f;
  --bg-card: #131d38;
  --line: rgba(201, 162, 75, 0.18);
  --gold: #c9a24b;
  --gold-bright: #e8cd83;
  --parchment: #f3ecdb;
  --muted: #93a0c2;
  --muted-dim: #5d6788;
  --beyond-bg: #1c1530;
  --beyond-card: #241a3d;
  --beyond-accent: #b79ce0;
  --beyond-line: rgba(183, 156, 224, 0.25);
  --star-hard: #c1666b;

  --font-display: "Noto Serif KR", serif;
  --font-body: "Pretendard", "Noto Sans KR", sans-serif;
  --font-latin: "EB Garamond", "Cormorant Garamond", serif;

  --radius: 4px;
  --max-width: 1120px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--parchment);
  font-family: var(--font-body);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Nav ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 15, 31, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.site-nav .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--gold-bright);
}
.brand small {
  display: block;
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.08em;
}
.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
}
.nav-links a {
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--gold-bright); }
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  padding: 0;
  align-items: center;
}
.nav-toggle span {
  width: 15px;
  height: 1px;
  background: var(--gold-bright);
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 720px) {
  .nav-toggle { display: flex; }
  .nav-links {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--line);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .nav-links.open { max-height: 320px; }
  .nav-links li { width: 100%; }
  .nav-links a {
    display: block;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    font-size: 1rem;
  }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 96px 0 72px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.hero-portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 78% 30%;
  z-index: 0;
  opacity: 0.55;
}
.hero-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(100deg, var(--bg) 0%, rgba(10, 15, 31, 0.92) 34%, rgba(10, 15, 31, 0.55) 62%, rgba(10, 15, 31, 0.28) 100%),
    linear-gradient(0deg, var(--bg) 0%, rgba(10, 15, 31, 0) 22%);
}
.hero > .wrap { position: relative; z-index: 2; }
@media (max-width: 900px) {
  .hero-portrait { opacity: 0.32; object-position: 70% 20%; }
  .hero-scrim {
    background:
      linear-gradient(180deg, rgba(10,15,31,0.75) 0%, rgba(10,15,31,0.92) 55%, var(--bg) 100%);
  }
}
.hero-eyebrow {
  font-family: var(--font-latin);
  font-style: italic;
  color: var(--gold);
  letter-spacing: 0.12em;
  font-size: 0.95rem;
  margin-bottom: 18px;
}
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1.25;
  margin: 0 0 20px;
  max-width: 14ch;
}
.hero h1 em {
  font-style: italic;
  color: var(--gold-bright);
}
.hero p.lede {
  max-width: 52ch;
  color: var(--muted);
  font-size: 1.08rem;
  margin-bottom: 40px;
}
.hero-stats {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}
.stat .num {
  font-family: var(--font-display);
  font-size: 2.1rem;
  color: var(--gold-bright);
  line-height: 1;
}
.stat .label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 6px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--gold);
  color: #17110a;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: var(--radius);
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s, transform 0.15s;
}
.btn:hover { background: var(--gold-bright); transform: translateY(-1px); }
.btn.ghost {
  background: transparent;
  color: var(--gold-bright);
  border: 1px solid var(--gold);
}
.btn.ghost:hover { background: rgba(201,162,75,0.1); }

/* Orbit signature visual */
.orbit-signature {
  position: absolute;
  right: -60px;
  top: 40px;
  width: 460px;
  height: 460px;
  opacity: 0.9;
  pointer-events: none;
  z-index: 1;
}
@media (max-width: 900px) {
  .orbit-signature { display: none; }
}
.orbit-signature svg { width: 100%; height: 100%; }
.orbit-path {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.orbit-dot {
  fill: var(--gold-bright);
  filter: drop-shadow(0 0 6px rgba(232, 205, 131, 0.8));
}
.orbit-dot-2 { fill: var(--beyond-accent); filter: drop-shadow(0 0 6px rgba(183,156,224,0.7)); }

@keyframes orbitMove {
  from { offset-distance: 0%; }
  to { offset-distance: 100%; }
}

/* ---------- Section headers ---------- */
.section {
  padding: 88px 0;
  border-bottom: 1px solid var(--line);
}
.section-head {
  margin-bottom: 44px;
  max-width: 60ch;
}
.eyebrow {
  font-family: var(--font-latin);
  font-style: italic;
  color: var(--gold);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}
.section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: 0 0 14px;
}
.section p.desc { color: var(--muted); }

/* ---------- Today's card ---------- */
.today-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 36px;
}
@media (max-width: 720px) {
  .today-card { grid-template-columns: 1fr; }
}
.today-badge {
  font-family: var(--font-latin);
  font-style: italic;
  color: var(--gold);
  font-size: 0.85rem;
}
.today-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 10px 0 0;
}

/* ---------- Search ---------- */
.search-wrap { position: relative; margin-bottom: 20px; }
.search-box {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 18px;
  gap: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s;
}
.search-box:focus-within { border-color: var(--gold); }
.search-box span {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}
.search-box span::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 1.5px;
  background: var(--muted);
  right: -6px;
  bottom: -2px;
  transform: rotate(45deg);
}
.search-box input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.search-box input::placeholder { color: var(--muted-dim); }
.search-box button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.search-box button:hover { color: var(--gold-bright); }
.search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 420px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
}
.search-results[hidden] { display: none; }
.search-results-head {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted-dim);
}
.search-results-head strong { color: var(--gold-bright); }
.search-result-item {
  display: flex;
  width: 100%;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  border-top: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  align-items: baseline;
}
.search-result-item:hover { background: var(--bg-card); }
.search-result-item b { color: var(--gold); font-family: var(--font-latin); font-style: italic; flex: 0 0 auto; }
.search-result-item .srt { flex: 1; min-width: 0; }
.search-result-item strong { display: block; color: var(--parchment); font-size: 0.92rem; }
.search-result-item small { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-no-result { padding: 18px 16px; color: var(--muted); font-size: 0.88rem; }

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 36px;
  align-items: center;
}
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--gold); color: var(--parchment); }
.chip.active {
  background: var(--gold);
  color: #17110a;
  border-color: var(--gold);
  font-weight: 600;
}
.filter-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}
.result-count {
  color: var(--muted-dim);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

/* ---------- Card grid ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.empty-state {
  grid-column: 1 / -1;
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
}
.pcard {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 22px;
  cursor: pointer;
  transition: border-color 0.18s, transform 0.18s;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 190px;
}
.pcard:hover {
  border-color: var(--gold);
  transform: translateY(-3px);
}
.pcard-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.pcard-ref {
  font-family: var(--font-latin);
  font-style: italic;
  color: var(--gold);
  font-size: 0.78rem;
}
.pcard-stars { color: var(--gold-bright); font-size: 0.8rem; white-space: nowrap; }
.pcard-stars.hard { color: var(--star-hard); }
.pcard-title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  line-height: 1.4;
  margin: 0;
}
.pcard-themes {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
}

/* Beyond (Part 6) distinct styling */
.section.beyond {
  background: var(--beyond-bg);
  border-bottom: 1px solid var(--beyond-line);
}
.section.beyond .eyebrow { color: var(--beyond-accent); }
.section.beyond .pcard {
  background: var(--beyond-card);
  border-color: var(--beyond-line);
}
.section.beyond .pcard:hover { border-color: var(--beyond-accent); }
.section.beyond .pcard-ref { color: var(--beyond-accent); }
.section.beyond .tag { border-color: var(--beyond-line); }
.section.beyond .btn.ghost { border-color: var(--beyond-accent); color: var(--beyond-accent); }
.section.beyond .btn.ghost:hover { background: rgba(183,156,224,0.12); }

/* ---------- Themes grid ---------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.theme-tile {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.theme-tile:hover { border-color: var(--gold); background: var(--bg-elevated); }
.theme-tile .n {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--gold-bright);
}
.theme-tile .name { margin-top: 6px; font-weight: 600; }
.theme-tile .count { color: var(--muted-dim); font-size: 0.82rem; margin-top: 4px; }

/* ---------- About ---------- */
.about-long {
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}
.about-entry {
  position: relative;
  padding-left: 64px;
  padding-top: 36px;
  border-top: 1px solid var(--line);
}
.about-entry:first-child { padding-top: 0; border-top: none; }
.about-num {
  position: absolute;
  left: 0;
  top: 36px;
  font-family: var(--font-latin);
  font-style: italic;
  font-size: 1rem;
  color: var(--gold);
  opacity: 0.8;
}
.about-entry:first-child .about-num { top: 2px; }
.about-entry h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--gold-bright);
  margin: 0 0 14px;
}
.about-body p { color: var(--muted); line-height: 1.85; margin: 0 0 14px; }
.about-body p:last-child { margin-bottom: 0; }
.about-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.about-list li {
  color: var(--muted);
  line-height: 1.8;
  padding-left: 18px;
  position: relative;
}
.about-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.7em;
  width: 6px;
  height: 1px;
  background: var(--gold);
}
.about-list strong { color: var(--parchment); font-weight: 600; }
.about-quote {
  border-left: 3px solid var(--gold);
  padding: 4px 0 4px 20px;
  margin: 0 0 14px;
  font-family: var(--font-latin);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--parchment);
  line-height: 1.7;
}
.about-quote cite {
  display: block;
  margin-top: 10px;
  font-family: var(--font-body);
  font-style: normal;
  font-size: 0.78rem;
  color: var(--muted-dim);
}
@media (max-width: 640px) {
  .about-entry { padding-left: 0; padding-top: 28px; }
  .about-num { position: static; display: block; margin-bottom: 8px; }
  .about-entry:first-child .about-num { position: static; }
}

/* ---------- Footer ---------- */
footer {
  padding: 40px 0;
  color: var(--muted-dim);
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--gold-bright); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 20, 0.78);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  z-index: 100;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--gold);
  border-radius: 8px;
  max-width: 720px;
  width: 100%;
  padding: 40px;
  position: relative;
  animation: modalIn 0.2s ease-out;
}
.modal.beyond-modal {
  border-color: var(--beyond-accent);
  background: var(--beyond-card);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: var(--gold-bright); }
.modal-badge {
  font-family: var(--font-latin);
  font-style: italic;
  color: var(--gold);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.modal.beyond-modal .modal-badge { color: var(--beyond-accent); }
.modal h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin: 0 0 8px;
}
.modal .stars { color: var(--gold-bright); font-size: 0.9rem; margin-bottom: 24px; }
.modal .stars.hard { color: var(--star-hard); }
.modal-quote {
  border-left: 3px solid var(--gold);
  padding: 4px 0 4px 20px;
  margin: 0 0 24px;
  font-family: var(--font-latin);
  font-size: 1.12rem;
  font-style: italic;
  color: var(--parchment);
  line-height: 1.7;
}
.modal.beyond-modal .modal-quote { border-left-color: var(--beyond-accent); }
.modal-portrait {
  margin: 0 0 24px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.modal-portrait img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  object-position: 50% 15%;
  display: block;
}
.modal-diagram {
  margin: 0 0 24px;
  padding: 18px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(201, 162, 75, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.modal.beyond-modal .modal-diagram { border-color: var(--beyond-line); background: rgba(183, 156, 224, 0.05); }
.modal-diagram img { width: 100%; max-width: 380px; height: auto; display: block; }
.modal-diagram .modal-diagram-caption {
  font-size: 0.72rem;
  color: var(--muted-dim);
  letter-spacing: 0.03em;
}
.modal-analogy-image {
  margin-top: 12px;
}
.modal-analogy-image img {
  width: 100%;
  max-width: 320px;
  border-radius: 6px;
  display: block;
}
.modal-label {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-dim);
  margin: 22px 0 8px;
}
.modal-body p { margin: 0 0 14px; color: var(--parchment); }
.modal-analogy {
  background: rgba(201, 162, 75, 0.08);
  border-radius: 6px;
  padding: 14px 18px;
  margin-bottom: 12px;
  font-size: 0.96rem;
}
.modal.beyond-modal .modal-analogy { background: rgba(183, 156, 224, 0.1); }
.modal-reflect {
  font-style: italic;
  color: var(--gold-bright);
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 22px;
}
.modal.beyond-modal .modal-reflect { color: var(--beyond-accent); border-top-color: var(--beyond-line); }
.modal-related {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.modal-related a.chip { text-decoration: none; }
.modal-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.modal-table th, .modal-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.modal-table th { color: var(--gold); font-weight: 600; }

@media (max-width: 600px) {
  .modal { padding: 28px 20px; }
}
