/* ==========================================================================
   FREEDOBY Blog — Notion-style Theme
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;600;700&display=swap');

:root {
  --bg: #ffffff;
  --bg-subtle: #f7f6f3;          /* light gray panels / callouts */
  --bg-hover: #efefed;
  --text: #37352f;               /* near-black */
  --text-soft: #6b6a64;          /* secondary */
  --text-faint: #9b9a96;         /* tertiary / captions */
  --accent: #8b2e2e;             /* brand red — used sparingly */
  --accent-soft: #b85a5a;
  --border: #e8e7e3;
  --border-strong: #d7d6d2;
  --code-bg: #f4f3f1;
  --code-text: #b3261e;

  --font-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'JetBrains Mono', 'Courier New', monospace;

  --content-width: 760px;
  --layout-max: 1500px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-card: 0 1px 2px rgba(15, 15, 15, 0.05), 0 4px 14px rgba(15, 15, 15, 0.06);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  font-feature-settings: "kern", "liga";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; }

/* ========== GENERIC CONTAINERS ========== */

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

.container-wide {
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 0 40px;
}

/* ========== TOP BAR ========== */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  margin-bottom: 40px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 0 40px;
}

.site-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.site-title em {
  font-style: normal;
  font-weight: 400;
  color: var(--text-faint);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  gap: 4px;
  font-size: 14px;
}

.site-nav a {
  color: var(--text-soft);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
  padding: 6px 10px;
  border-radius: var(--radius);
}

.site-nav a:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ========== LAYOUT: SIDEBAR + CONTENT ========== */

.layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 44px;
  max-width: var(--layout-max);
  margin: 0 auto;
  padding: 0 40px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 64px;
  padding-top: 4px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.25s ease;
}
.sidebar:hover {
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
}
.sidebar:hover::-webkit-scrollbar-thumb {
  background: var(--border);
}

.sidebar-header {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

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

.sidebar-home {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius);
  margin-bottom: 4px;
  transition: background 0.12s, color 0.12s;
}

.sidebar-home:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-home.active {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
}

.sidebar-section {
  display: block;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 10px 4px;
  margin-top: 10px;
}

.sidebar-section:first-of-type {
  margin-top: 4px;
}

a.sidebar-section {
  text-decoration: none;
  border-radius: var(--radius);
  transition: color 0.12s, background 0.12s;
}

a.sidebar-section:hover {
  color: var(--text);
  background: var(--bg-hover);
}

a.sidebar-section.active {
  color: var(--accent);
}

.sidebar-link {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  text-decoration: none;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.4;
  border-radius: var(--radius);
  transition: background 0.12s, color 0.12s;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-link.active {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
}

.sidebar-link .num {
  flex: none;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.sidebar-link .sidebar-ext {
  flex: none;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-faint);
}

.layout-content {
  min-width: 0;
  padding-bottom: 80px;
}

/* Sidebar collapses on small screens */
@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 24px;
  }
  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    margin-bottom: 36px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
  }
  .sidebar-nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
  }
  .sidebar-home,
  .sidebar-header,
  .sidebar-section {
    grid-column: 1 / -1;
  }
  .site-header-inner { padding: 0 24px; }
}

@media (max-width: 560px) {
  .sidebar-nav { grid-template-columns: 1fr; }
}

/* ========== PAGE HERO (home / slides hub) ========== */

.page-hero {
  max-width: var(--content-width);
  margin-bottom: 48px;
}

.page-title {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 12px;
}

.page-desc {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-soft);
  max-width: 560px;
}

/* ========== GALLERY (Notion-style card grid) ========== */

.gallery-heading {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 44px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.gallery-heading:first-of-type { margin-top: 0; }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.gallery-card:hover {
  box-shadow: var(--shadow-card);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.gallery-cover {
  aspect-ratio: 16 / 9;
  background: var(--bg-subtle);
  overflow: hidden;
}

.gallery-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.gallery-card:hover .gallery-cover img {
  transform: scale(1.03);
}

.gallery-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.gallery-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.gallery-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 8px;
  word-break: keep-all;
}

.gallery-excerpt {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-soft);
  margin-bottom: 14px;
}

.gallery-tags {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-faint);
  letter-spacing: 0.01em;
}

/* ========== ARTICLE ========== */

.article {
  max-width: var(--content-width);
  margin: 0 auto;
  padding-bottom: 64px;
}

.page-cover {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  margin-bottom: 28px;
}

.page-cover img {
  display: block;
  width: 100%;
  height: auto;
}

.article-header {
  text-align: left;
  margin: 0 0 36px;
}

.article-number {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
  display: block;
}

.article-title {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  color: var(--text);
}

.article-title-sub {
  display: block;
  font-size: 0.6em;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-soft);
  margin-top: 10px;
}

.article-subtitle {
  font-style: normal;
  font-size: 17px;
  color: var(--text-soft);
  line-height: 1.6;
}

.article-divider {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 28px 0 0;
  border: none;
}

/* ----- Typography within article ----- */

.article h2 {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 48px 0 14px;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.article h3 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  margin: 32px 0 10px;
  color: var(--text);
}

.article h4 {
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text);
}

.article p {
  margin-bottom: 14px;
  color: var(--text);
}

.article strong {
  font-weight: 700;
  color: var(--text);
}

.article em {
  font-style: italic;
}

.article a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(139, 46, 46, 0.35);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.12s;
}

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

/* Lists */
.article ul,
.article ol {
  margin: 14px 0 18px;
  padding-left: 26px;
}

.article li {
  margin-bottom: 7px;
  line-height: 1.7;
}

.article ul li::marker { color: var(--text-faint); }
.article ol li::marker { color: var(--text-faint); font-family: var(--font-mono); }

/* Blockquote → Notion callout */
.article blockquote {
  margin: 22px 0;
  padding: 16px 18px 16px 50px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-style: normal;
  font-size: 16px;
  color: var(--text);
  line-height: 1.65;
  position: relative;
}

.article blockquote::before {
  content: "💡";
  position: absolute;
  left: 16px;
  top: 15px;
  font-size: 18px;
  line-height: 1.4;
}

.article blockquote p { margin-bottom: 8px; }
.article blockquote p:last-child { margin-bottom: 0; }
.article blockquote strong { color: var(--text); }

/* Emphasized "막히면" troubleshooting callout */
.article blockquote.tip {
  border-color: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding-left: 50px;
}
.article blockquote.tip::before { content: "🆘"; }
.article blockquote.tip strong { color: var(--accent); }

/* Code */
.article code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--code-text);
}

.article pre {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 22px 0;
  overflow-x: auto;
  color: var(--text);
}

.article pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Toggle (details/summary) — Notion-style */
.article details.toggle {
  margin: 20px 0;
  border-bottom: 1px solid var(--border);
}

.article details.toggle > summary {
  cursor: pointer;
  list-style: none;
  padding: 10px 0 10px 26px;
  position: relative;
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
}

.article details.toggle > summary::-webkit-details-marker { display: none; }

.article details.toggle > summary::before {
  content: "▸";
  position: absolute;
  left: 4px;
  color: var(--text-faint);
  transition: transform 0.15s;
}

.article details.toggle[open] > summary::before { transform: rotate(90deg); }

.article details.toggle > summary + * { margin-top: 8px; }
.article details.toggle > *:not(summary) { margin-left: 26px; }
.article details.toggle[open] { padding-bottom: 14px; }

/* Tables */
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.article th {
  font-weight: 700;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 14px;
}

.article td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.article tr:last-child td { border-bottom: none; }

/* Figures / images */
.article figure {
  margin: 24px 0;
  text-align: center;
}

.article figure img {
  max-width: 100%;
  max-height: 540px;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  object-fit: contain;
}

.article figcaption {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-faint);
  line-height: 1.5;
}

/* Horizontal rule */
.article hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 44px 0;
}

/* ----- Prev / next navigation ----- */
.article-nav {
  border-top: 1px solid var(--border);
  padding-top: 28px;
  margin-top: 56px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.article-nav a {
  text-decoration: none;
  color: inherit;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: box-shadow 0.16s, border-color 0.16s;
  display: block;
}

.article-nav a:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
}

.article-nav .label {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 6px;
  display: block;
}

.article-nav .title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.article-nav .next { text-align: right; }

.article-nav .prev.empty,
.article-nav .next.empty { visibility: hidden; }

/* ========== SITE FOOTER ========== */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 48px;
  margin-top: 56px;
  text-align: center;
  font-size: 14px;
  color: var(--text-faint);
}

.site-footer p { margin-bottom: 6px; }

.site-footer a {
  color: var(--text-soft);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

.site-footer a:hover { color: var(--accent); text-decoration-color: var(--accent); }

.license-notice {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.02em;
  margin-top: 14px;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: inline-block;
  background: var(--bg-subtle);
}

/* ========== UTILITIES ========== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

::selection {
  background: rgba(139, 46, 46, 0.14);
  color: var(--text);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
  .page-title { font-size: 30px; }
  .article-title { font-size: 30px; }
  .article h2 { font-size: 23px; margin: 40px 0 14px; }
  .article h3 { font-size: 19px; }
  .article-nav { grid-template-columns: 1fr; }
  .article-nav .next { text-align: left; }
  .site-header-inner { padding: 0 16px; }
  .gallery { grid-template-columns: 1fr; }
}

/* Practice — intro note box on the hub page */
.practice-note {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-top: 8px;
  color: var(--text);
  line-height: 1.7;
}

.practice-note p { margin: 0 0 12px; }
.practice-note p:last-child { margin-bottom: 0; }
.practice-note ul { margin: 12px 0; padding-left: 22px; }
.practice-note li { margin: 6px 0; }

/* Copyable command/prompt blocks — copy button auto-injected by script */
.article pre {
  position: relative;
  white-space: pre-wrap;
  word-break: break-word;
  padding-right: 84px;
}
.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 12px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.copy-btn:hover { color: var(--text); border-color: var(--text-faint); background: var(--bg-hover); }
.copy-btn.copied { color: #fff; background: var(--accent); border-color: var(--accent); }

/* Inline code outside .article (hub gallery, note box) */
.gallery-excerpt code,
.practice-note code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
  color: var(--code-text);
}
