/* ==========================================================================
   Cloud Temple — Research Papers
   Design system inspired by starter-kit (dark theme + teal accent)
   ========================================================================== */

:root {
    --bg: #0f0f23;
    --bg-grad: linear-gradient(180deg, #0d0d20 0%, #0f0f23 100%);
    --surface: #1a1a2e;
    --surface-2: #222240;
    --surface-3: #2a2a48;
    --accent: #41a890;
    --accent-hover: #4fc2a8;
    --accent-soft: rgba(65, 168, 144, 0.12);
    --accent-soft-strong: rgba(65, 168, 144, 0.22);
    --accent-border: rgba(65, 168, 144, 0.35);
    --text: #e6e6ee;
    --text-2: #a8a8c0;
    --muted: #6e6e88;
    --danger: #e74c3c;
    --warning: #f39c12;
    --success: #27ae60;
    --border: #2a2a48;
    --border-soft: rgba(42, 42, 72, 0.6);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--accent-border);
    --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-grad);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); }

button { font-family: inherit; cursor: pointer; }

.hidden { display: none !important; }

/* ═══ HEADER ═══ */
.site-header {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-bottom: 2px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: saturate(140%) blur(8px);
}
.header-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text);
}
.header-brand:hover { color: var(--text); }
.header-logo { height: 28px; display: block; }
.header-sep { color: rgba(255, 255, 255, 0.25); font-size: 1.4rem; font-weight: 200; }
.header-title { font-size: 1rem; font-weight: 500; color: rgba(255, 255, 255, 0.88); letter-spacing: 0.01em; }

.header-nav {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    font-size: 0.85rem;
}
.header-nav a {
    color: var(--text-2);
    font-weight: 500;
    transition: color .15s;
}
.header-nav a:hover { color: var(--accent); }
.header-github { display: inline-flex; align-items: center; }

/* ═══ HERO ═══ */
.hero {
    padding: 4rem 1.5rem 2.5rem;
    text-align: center;
    background: radial-gradient(ellipse at top, rgba(65, 168, 144, 0.08) 0%, transparent 60%);
}
.hero-inner { max-width: 760px; margin: 0 auto; }
.hero h1 {
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    margin-bottom: 0.6rem;
}
.hero-subtitle {
    color: var(--text-2);
    font-size: 1.05rem;
    margin-bottom: 2rem;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.search-wrap {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}
.search-wrap input {
    width: 100%;
    height: 52px;
    padding: 0 3rem 0 3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 26px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus {
    border-color: var(--accent);
    background: var(--surface-2);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.search-icon {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}
.search-wrap input:focus ~ .search-icon { color: var(--accent); }
.clear-btn {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-2);
    color: var(--text-2);
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.clear-btn:hover { background: var(--accent); color: #fff; }

/* ═══ FILTERS ═══ */
.filters-section { padding: 0.5rem 1.5rem 1rem; }
.filters-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}
.tag-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1;
}
.tag-chip {
    padding: 0.35rem 0.85rem;
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
    white-space: nowrap;
}
.tag-chip:hover { color: var(--text); border-color: var(--accent-border); background: var(--surface-2); }
.tag-chip.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-border);
}
.tag-chip .count {
    display: inline-block;
    margin-left: 0.3rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
}
.tag-chip.active .count { color: var(--accent); }

.sort-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-2);
}
.sort-wrap select {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.7rem;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}
.sort-wrap select:focus { border-color: var(--accent); }

/* ═══ PAPERS GRID ═══ */
.papers-section { padding: 1rem 1.5rem 4rem; }
.papers-inner { max-width: 1240px; margin: 0 auto; }
.results-meta {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.results-meta #results-count { color: var(--accent); font-size: 1rem; }

.papers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.4rem;
}

.paper-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .2s, box-shadow .2s, border-color .2s;
    box-shadow: var(--shadow-card);
    position: relative;
}
.paper-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-card-hover);
}
.paper-card.featured::before {
    content: "★ Latest publication";
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    z-index: 2;
    padding: 0.25rem 0.7rem;
    background: var(--accent);
    color: #fff;
    border-radius: 100px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(65, 168, 144, 0.4);
}

.paper-card.embargo::before {
    content: "🔒 Embargo";
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    z-index: 3;
    padding: 0.25rem 0.7rem;
    background: var(--warning);
    color: #1a1a2e;
    border-radius: 100px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}
.paper-card.embargo .paper-thumb img {
    filter: blur(4px) grayscale(20%);
    opacity: 0.55;
}
.paper-card.embargo:hover .paper-thumb img { transform: none; }
.paper-thumb-lock {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: var(--warning);
    background: linear-gradient(180deg, rgba(15, 15, 35, 0.35) 0%, rgba(15, 15, 35, 0.55) 100%);
    text-transform: uppercase;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    z-index: 2;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.paper-thumb-lock svg {
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

.embargo-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    margin-top: 0.4rem;
    background: rgba(243, 156, 18, 0.08);
    border: 1px solid rgba(243, 156, 18, 0.3);
    border-radius: var(--radius-sm);
    color: var(--warning);
    font-size: 0.78rem;
    line-height: 1.45;
}
.embargo-banner svg { flex-shrink: 0; margin-top: 2px; }
.embargo-banner span { color: var(--text-2); }

.paper-actions .btn[disabled],
.paper-actions .btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.paper-thumb {
    aspect-ratio: 4 / 3;
    background: #fff;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
}
.paper-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
    transition: transform .3s;
}
.paper-card:hover .paper-thumb img { transform: scale(1.04); }
.paper-thumb-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(15, 15, 35, 0.05) 100%);
    pointer-events: none;
}

.paper-body {
    padding: 1.1rem 1.2rem 1.2rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.7rem;
}

.paper-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.paper-meta .venue {
    color: var(--accent);
    background: var(--accent-soft);
    padding: 0.15rem 0.55rem;
    border-radius: 100px;
    letter-spacing: 0.03em;
    font-size: 0.68rem;
}
.paper-meta .lang {
    background: var(--surface-2);
    color: var(--text-2);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
}

.paper-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.35;
    letter-spacing: -0.005em;
}
.paper-subtitle {
    font-size: 0.85rem;
    color: var(--text-2);
    font-style: italic;
    margin-top: -0.3rem;
}

.paper-authors {
    font-size: 0.82rem;
    color: var(--text-2);
}
.paper-authors strong { color: var(--text); font-weight: 500; }

.paper-abstract {
    font-size: 0.85rem;
    color: var(--text-2);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.paper-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: auto;
    padding-top: 0.4rem;
}
.tag {
    padding: 0.2rem 0.55rem;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.tag:hover { background: var(--accent-soft-strong); }

.paper-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-soft);
}

/* ═══ BUTTONS ═══ */
.btn {
    flex: 1;
    padding: 0.55rem 0.9rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all .15s;
    text-decoration: none;
}
.btn svg { flex-shrink: 0; }
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}
.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border-color: var(--border);
}
.btn-ghost:hover {
    color: var(--accent);
    border-color: var(--accent-border);
    background: var(--accent-soft);
}

/* ═══ EMPTY STATE ═══ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted);
}
.empty-state p { margin-bottom: 1rem; font-size: 1rem; }

/* ═══ FOOTER ═══ */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 1.4rem 1.5rem;
    margin-top: auto;
}
.footer-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    font-size: 0.82rem;
    color: var(--text-2);
}
.footer-sep { color: var(--muted); }

/* ═══ PDF READER MODAL ═══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
}
.modal-overlay.active { display: flex; }
.modal-pdf {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: min(1100px, 100%);
    height: min(900px, 95vh);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-pdf-header {
    padding: 0.8rem 1.2rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.modal-pdf-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.modal-pdf-actions { display: flex; gap: 0.5rem; }
.modal-pdf-actions .btn { flex: none; }
.modal-pdf iframe {
    flex: 1;
    border: none;
    background: #1a1a1a;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
    .hero { padding: 2.5rem 1rem 1.5rem; }
    .hero h1 { font-size: 1.7rem; }
    .hero-subtitle { font-size: 0.95rem; }
    .header-inner { padding: 0 1rem; }
    .filters-inner { flex-direction: column; align-items: stretch; }
    .papers-grid { grid-template-columns: 1fr; gap: 1rem; }
    .modal-overlay { padding: 0; }
    .modal-pdf { border-radius: 0; height: 100vh; width: 100%; }
}

@media (max-width: 480px) {
    .header-nav a:not(.header-github) { display: none; }
    .paper-card.featured::before { font-size: 0.6rem; padding: 0.2rem 0.5rem; }
}

/* ═══ SUBTLE ANIMATIONS ═══ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.paper-card { animation: fadeUp .3s ease-out both; }
.paper-card:nth-child(1) { animation-delay: 0.02s; }
.paper-card:nth-child(2) { animation-delay: 0.05s; }
.paper-card:nth-child(3) { animation-delay: 0.08s; }
.paper-card:nth-child(4) { animation-delay: 0.11s; }
.paper-card:nth-child(5) { animation-delay: 0.14s; }
.paper-card:nth-child(6) { animation-delay: 0.17s; }
