/* ============================================================
   PREMIUM DESIGN SYSTEM (shadcn/rdot refined)
   ============================================================ */

:root {
    /* === COLOR PALETTE === */
    --color-brand: 206 85% 54%;
    --color-brand-light: 206 85% 88%;
    --color-brand-dark: 206 85% 18%;

    --color-surface: 0 0% 100%;
    --color-surface-muted: 240 4.8% 95.9%;
    --color-text: 240 10% 3.9%;
    --color-text-secondary: 240 3.8% 46.1%;
    --color-border: 240 5.9% 90%;
    --color-focus-ring: 240 5% 64.9%;

    /* === SEMANTIC ALIASES === */
    --bg-base: #f8f5ee;
    --bg-elevated: #f0ebe3;
    --bg-header: rgba(240, 235, 227, 0.88);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-card: hsl(var(--color-surface));
    --bg-muted: hsl(var(--color-surface-muted));

    --text-primary: hsl(var(--color-text));
    --text-secondary: hsl(var(--color-text-secondary));
    --text-accent: hsl(var(--color-brand));
    --text-code: hsl(206 85% 35%);

    --border-default: hsl(var(--color-border));
    --border-accent: hsl(var(--color-brand) / 0.3);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --highlight-bg: hsl(var(--color-brand-light));
    --highlight-text: hsl(var(--color-brand-dark));

    --radius: 0.6rem;
    --max-width: 600px;
}

[data-theme="dark"] {
    --color-brand: 206 85% 54%;
    --color-brand-light: 206 85% 18%;
    --color-brand-dark: 206 85% 75%;

    --color-surface: 240 10% 4.9%;
    --color-surface-muted: 240 3.7% 15.9%;
    --color-text: 0 0% 98%;
    --color-text-secondary: 240 5% 64.9%;
    --color-border: 240 3.7% 15.9%;
    --color-focus-ring: 240 4.9% 83.9%;

    --bg-base: #181613;
    --bg-elevated: #161412;
    --bg-header: rgba(22, 20, 18, 0.88);
    --bg-glass: rgba(26, 24, 22, 0.7);
    --bg-card: hsl(var(--color-surface));
    --bg-muted: hsl(var(--color-surface-muted));

    --text-code: hsl(206 85% 60%);
    --highlight-bg: hsl(var(--color-brand-light));
    --highlight-text: hsl(var(--color-brand-dark));
}

/* ============================================================
   BASE & RESET
   ============================================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR",
        sans-serif, "Apple Color Emoji";
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease;
}

a {
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
   HEADER (Premium Glassmorphism)
   ============================================================ */
.site-header {
    padding: 80px 0 40px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 24px;
}

.home-search-area {
    text-align: center;
    padding: 20px 0;
}

.home-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.home-hint kbd {
    background: var(--bg-muted);
    border: 1px solid var(--border-default);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: inherit;
    font-size: 0.8rem;
}

.site-logo {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.05em;
}

.site-logo span {
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 2px;
}

.header-search {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.header-actions a {
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.header-actions a:hover {
    color: var(--text-accent);
}

.header-actions button {
    padding: 10px;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.header-actions button:hover {
    background: var(--bg-muted);
    color: var(--text-accent);
}

.header-search input {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 38px;
    background: var(--bg-muted);
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-search input:focus {
    background: hsl(var(--color-surface));
    border-color: var(--text-accent);
    box-shadow: 0 0 0 4px hsl(var(--color-brand) / 0.1);
}

.header-search:focus-within .search-icon {
    color: var(--text-accent);
}

.header-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
    opacity: 0.7;
}

/* ============================================================
   PAGEFIND SEARCH DROPDOWN
   ============================================================ */
#pagefind-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: hsl(var(--color-surface));
    border: 1px solid var(--border-default);
    border-radius: calc(var(--radius) + 2px);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 1100;
    max-height: 400px;
    overflow-y: auto;
    animation: slideDown 0.2s ease-out;
}

#pagefind-dropdown.open {
    display: block;
}

.pf-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pf-result {
    display: block;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-default);
    transition: background 0.15s ease;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.pf-result:last-child {
    border-bottom: none;
}

.pf-result:hover,
.pf-result.pf-active {
    background: var(--bg-muted);
    color: var(--text-accent);
}

.pf-result mark {
    background: var(--highlight-bg);
    color: var(--highlight-text);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Highlight */
mark {
    background: var(--highlight-bg);
    color: var(--highlight-text);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 500;
}

/* ============================================================
   FEED (Home)
   ============================================================ */
.recent-posts {
    padding-top: 16px;
}

.post-feed {
    padding: 0 0 80px;
}


.post-card-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    overflow: visible;
}

.post-card {
    flex: 1;
    display: block;
    padding: 28px 50px 28px 0;
    border-bottom: 1px solid var(--border-default);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
    max-width: calc(100% - 40px);
}

.post-card:last-child {
    border-bottom: none;
}

.post-card:hover {
    transform: translateX(4px);
}

.post-card:hover .pc-title {
    color: var(--text-accent);
}

.pc-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pc-avatar {
    width: 24px;
    height: 24px;
    background: var(--bg-muted);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.pc-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.25;
    margin-bottom: 10px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pc-excerpt {
    font-size: 0.925rem;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
}

/* ============================================================
   CONTENT TYPOGRAPHY (Clean & Readable)
   ============================================================ */
.post-header {
    padding: 60px 0 40px;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--border-default);
}

.post-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.post-back:hover {
    color: var(--text-primary);
}

.post-title {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin-bottom: 20px;
}

.post-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    padding-bottom: 120px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.post-content h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 2.5em 0 1em;
    letter-spacing: -0.02em;
}

.post-content h3 {
    font-size: 1.3rem;
    margin: 2em 0 0.8em;
}

.post-content p {
    margin-bottom: 1.5em;
}

.post-content blockquote {
    padding: 16px 24px;
    margin: 2em 0;
    background: var(--bg-muted);
    border-left: 4px solid var(--border-default);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--text-secondary);
}

.post-content pre {
    margin: 2em 0;
    border-radius: var(--radius);
    overflow-x: auto;
    max-width: 100%;
    box-shadow: var(--shadow-md);
    font-size: 0.9rem;
}

.post-content pre code.hljs {
    border-radius: var(--radius);
    padding: 20px 24px;
}

.post-content :not(pre)>code {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85em;
    background: var(--bg-muted);
    color: var(--text-code);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border-default);
}

.post-content img {
    max-width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin: 2em 0;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 0.9rem;
}

.post-content th,
.post-content td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-default);
    text-align: left;
}

.post-content th {
    background: var(--bg-muted);
    font-weight: 600;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--color-focus-ring));
}

/* ============================================================
   FOLDER LIST
   ============================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 32px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.breadcrumb a:hover {
    color: var(--text-primary);
}

.breadcrumb-sep {
    margin: 0 4px;
    opacity: 0.5;
}

.breadcrumb-current {
    color: var(--text-accent);
    font-weight: 600;
}

.folder-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 80px;
}

.folder-item-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.folder-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.folder-item:hover {
    background: var(--bg-muted);
    border-color: var(--border-accent);
}

.fi-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.fi-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.fi-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ============================================================
   COPY BUTTONS
   ============================================================ */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-muted);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: hsl(var(--color-brand) / 0.15);
    color: var(--text-accent);
}

.copy-btn.copied {
    background: hsl(var(--color-brand) / 0.2);
    color: var(--text-accent);
}

.copy-btn.copied .icon-copy {
    display: none;
}

.copy-btn .icon-check {
    display: none;
}

.copy-btn.copied .icon-check {
    display: inline;
}

.copy-btn.copied .copy-text::after {
    content: 'ied!';
}

.copy-btn .copy-text::after {
    content: '';
}

.card-copy-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    color: var(--text-secondary);
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
    flex-shrink: 0;
}

.folder-item-wrapper:hover .card-copy-btn,
.post-card-wrapper:hover .card-copy-btn {
    opacity: 1;
}

.card-copy-btn:hover {
    background: hsl(var(--color-brand) / 0.15);
    border-color: var(--border-accent);
    color: var(--text-accent);
}

.card-copy-btn.copied {
    background: hsl(var(--color-brand) / 0.2);
    color: var(--text-accent);
    border-color: hsl(var(--color-brand) / 0.4);
}

.card-copy-btn.copied .icon-copy {
    display: none;
}

.card-copy-btn .icon-check {
    display: none;
}

.card-copy-btn.copied .icon-check {
    display: block;
}

/* ============================================================
   PRODUCTS GRID
   ============================================================ */
.home-products {
    padding: 20px 0 60px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
}

.product-card {
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.2s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-accent);
    box-shadow: var(--shadow-md);
    background: var(--bg-muted);
}

.product-icon {
    margin-bottom: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--bg-muted);
    border-radius: 12px;
    border: 1px solid var(--border-default);
}

.product-icon img {
    margin: 0;
    box-shadow: none;
    border-radius: 0;
}

.product-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.product-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0;
}