@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Tokens ── */
:root {
    --bg: #000000;
    --bg-deep: #111111;
    --text: #eeeeee;
    --text-dim: #a0a0a0;
    --text-muted: #666666;
    --accent: #ffffff;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme='light'] {
    --bg: #ffffff;
    --bg-deep: #f0f0f0;
    --text: #111111;
    --text-dim: #666666;
    --text-muted: #aaaaaa;
    --accent: #333333;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow-x: visible;
    min-height: 100vh;
    transition: background 0.5s ease, color 0.5s ease;
    -webkit-font-smoothing: antialiased;
    cursor: default;
}

/* ── Minimal Nav ── */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 2.5rem;
    pointer-events: none;
}

.nav > * { pointer-events: auto; }

.nav-brand {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.2s ease;
    letter-spacing: 0.02em;
}
.nav-link:hover { color: var(--text); }

.theme-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    transition: all 0.2s ease;
}
[data-theme='light'] .theme-btn { border-color: rgba(0,0,0,0.1); }
.theme-btn:hover { color: var(--text); }
.theme-btn .icon-sun { display: none; }
.theme-btn .icon-moon { display: block; width: 16px; height: 16px; }
[data-theme='light'] .theme-btn .icon-sun { display: block; width: 16px; height: 16px; }
[data-theme='light'] .theme-btn .icon-moon { display: none; }

/* ── Full-page Layout ── */
.book-page {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: row;
    position: relative;
    overflow: visible;
}

/* ── Split Layout Sections ── */
.disc-section {
    flex: 0.65;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: flex 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.4s ease,
                border-color 0.4s ease;
}

[data-theme='light'] .disc-section {
    border-right-color: rgba(0, 0, 0, 0.05);
}

.fan-section {
    flex: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: visible;
}

/* ── Book Container ── */
.book-scene {
    perspective: 1750px;
    perspective-origin: 50% 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(-30deg);
    overflow: visible;
}

.book-tilt {
    transform-style: preserve-3d;
    transform: rotateX(-30deg);
}

.book {
    position: relative;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
    cursor: grab;
}

.book:active { cursor: grabbing; }

/* ── Individual Card / Page ── */
.page {
    width: 280px;
    height: 220px;
    flex-shrink: 0;
    position: absolute;
    top: calc(220px / -2);
    left: 0;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: grab;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transform-origin: 0% 50%;
}

.page:active { cursor: grabbing; }

.page img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 12px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Sheen overlay for each page */
.page-sheen {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    mix-blend-mode: overlay;
    z-index: 2;
}

.page:hover .page-sheen { opacity: 1; }


/* Default accordion fold angles — set by JS dynamically */

/* ── Floating Identity ── */
.identity {
    position: fixed;
    bottom: 2.5rem;
    left: 2.5rem;
    z-index: 50;
}

.identity-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
}

.identity-role {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 400;
}

/* ── Footer Links (bottom right) ── */
.foot-links {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.foot-link {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
    letter-spacing: 0.03em;
}
.foot-link:hover { color: var(--text); }

/* ── Drag hint ── */
.drag-hint {
    position: fixed;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    z-index: 10;
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    opacity: 1;
    transition: opacity 0.8s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 320px; /* below the book */
}

.drag-hint.hidden { opacity: 0; }

.drag-hint svg {
    width: 16px;
    height: 16px;
    animation: sway 2s ease-in-out infinite;
}

@keyframes sway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(6px); }
}

/* ── Card info tooltip ── */
.page-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
    border-radius: 0 0 12px 12px;
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 3;
    pointer-events: none;
}

.page:hover .page-label {
    opacity: 1;
    transform: translateY(0);
}

.page-label h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
}

.page-label p {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
    margin-top: 0.15rem;
}

/* ── Modal ── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.modal:not([aria-hidden="true"]) {
    opacity: 1;
    pointer-events: auto;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    background: var(--bg-deep);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
    transform: translateY(20px) scale(0.95);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

[data-theme='light'] .modal-content {
    background: var(--bg);
    border-color: rgba(0,0,0,0.1);
    box-shadow: 0 24px 80px rgba(0,0,0,0.15);
}

.modal:not([aria-hidden="true"]) .modal-content {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease;
}

.modal-close:hover { color: var(--text); }
.modal-close svg { width: 24px; height: 24px; }

.modal-body {
    display: flex;
    gap: 2.5rem;
    align-items: center;
}

#modal-img {
    width: 300px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

.modal-info {
    flex: 1;
}

.modal-info h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.modal-meta {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.modal-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-dim);
    background: rgba(255,255,255,0.02);
}

[data-theme='light'] .modal-tag {
    border-color: rgba(0,0,0,0.1);
    background: rgba(0,0,0,0.02);
}

#modal-desc {
    font-size: 1rem;
    color: var(--text-dim);
    line-height: 1.7;
    margin-bottom: 2.5rem;
}

.modal-link {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--text);
    color: var(--bg);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.modal-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

@media (max-width: 800px) {
    .modal-body { flex-direction: column; text-align: center; }
    .modal-meta { justify-content: center; }
    #modal-img { width: 100%; max-width: 240px; }
}

/* ── Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    .page { transition: none; }
}

/* ── 2D Disc Carousel Styles ── */
.disc-scene {
    position: relative;
    width: 100%;
    height: 100%;
}

.disc-bg-circle {
    position: absolute;
    left: 0; /* Center of circle on the left edge */
    top: 50%;
    transform: translate(-50%, -50%);
    width: 480px; /* 2 * radius (240px) */
    height: 480px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    animation: rotate-bg-slow 80s linear infinite;
}

[data-theme='light'] .disc-bg-circle {
    border-color: rgba(0, 0, 0, 0.08);
}

@keyframes rotate-bg-slow {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.disc-wheel {
    position: absolute;
    left: 0; /* Center of wheel on the left edge */
    top: 50%;
    width: 0;
    height: 0;
    transform-style: flat;
}

.disc-wheel .page {
    position: absolute;
    width: 180px;
    height: 120px; /* Adjusted height for badge content */
    margin-left: -90px;
    margin-top: -60px;
    transform-origin: center center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    transition: opacity 0.3s ease, transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.75rem;
    box-sizing: border-box;
}

[data-theme='light'] .disc-wheel .page {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.badge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.badge-logo {
    height: 24px;
    max-width: 70px;
    object-fit: contain;
}

.badge-status {
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    background: rgba(0, 255, 128, 0.15);
    color: #00ff80;
    border-radius: 20px;
    font-weight: 600;
}

[data-theme='light'] .badge-status {
    background: rgba(0, 180, 90, 0.1);
    color: #008f47;
}

.badge-status.completed {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

[data-theme='light'] .badge-status.completed {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.5);
}

.badge-info {
    margin: 0.25rem 0;
    text-align: left;
    width: 100%;
}

.badge-name {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    margin: 0 0 2px 0;
    color: var(--text);
}

.badge-role {
    font-size: 0.55rem;
    color: var(--text-muted);
    margin: 0 0 2px 0;
}

.badge-date {
    font-size: 0.5rem;
    color: var(--text-muted);
    opacity: 0.8;
    margin: 0;
}

.badge-footer {
    width: 100%;
    display: flex;
    align-items: center;
    margin-top: 2px;
}

.badge-barcode {
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, 
        var(--text) 0%, var(--text) 5%, 
        transparent 5%, transparent 10%, 
        var(--text) 10%, var(--text) 20%, 
        transparent 20%, transparent 25%, 
        var(--text) 25%, var(--text) 30%, 
        transparent 30%, transparent 40%, 
        var(--text) 40%, var(--text) 50%, 
        transparent 50%, transparent 60%, 
        var(--text) 60%, var(--text) 70%, 
        transparent 70%, transparent 80%, 
        var(--text) 80%, var(--text) 90%, 
        transparent 90%, transparent 95%, 
        var(--text) 95%, var(--text) 100%
    );
    opacity: 0.35;
}

.disc-wheel .page:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    .page { width: 200px; height: 195px; }
}

@media (max-width: 900px) {
    .book-page {
        flex-direction: column;
    }
    .disc-section {
        flex: 1;
        width: 100%;
        height: 42%;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    [data-theme='light'] .disc-section {
        border-bottom-color: rgba(0, 0, 0, 0.05);
    }
    .fan-section {
        flex: 1.2;
        width: 100%;
        height: 58%;
    }
    .disc-bg-circle {
        width: 280px;
        height: 280px;
    }
    .disc-wheel .page {
        width: 130px;
        height: 86px;
        margin-left: -65px;
        margin-top: -43px;
        padding: 0.5rem;
    }
    .badge-logo { height: 16px; max-width: 50px; }
    .badge-name { font-size: 0.6rem; }
    .badge-role { font-size: 0.45rem; }
    .badge-date { font-size: 0.4rem; }
    .badge-status { font-size: 0.4rem; padding: 1px 4px; }
    .badge-barcode { height: 4px; }
}

@media (max-width: 800px) {
    .page { width: 160px; height: 155px; }
    .nav { padding: 1rem 1.5rem; }
    .identity { bottom: 1.5rem; left: 1.5rem; }
    .foot-links { bottom: 1.5rem; right: 1.5rem; }
    .drag-hint { padding-top: 240px; }
}

@media (max-width: 550px) {
    .page { width: 130px; height: 125px; border-radius: 8px; }
    .page img { border-radius: 8px; }
    .page-sheen { border-radius: 8px; }
    .page-label { display: none; }
    .identity-name { font-size: 0.95rem; }
    .identity { bottom: 3.5rem; left: 1rem; }
    .foot-links { 
        bottom: 1rem; 
        right: 1rem; 
        gap: 0.5rem; 
        flex-wrap: wrap;
        max-width: calc(100% - 2rem);
        justify-content: flex-end;
    }
    .foot-link { font-size: 0.65rem; }
    .drag-hint { padding-top: 180px; font-size: 0.6rem; }
}

/* ── Password Protection Modal ── */
.password-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    opacity: 1;
    transition: opacity 0.4s ease;
}

.password-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Hide main content when password modal is shown */
body.password-locked .nav,
body.password-locked .book-page,
body.password-locked .identity,
body.password-locked .foot-links,
body.password-locked .modal {
    display: none !important;
}

.password-modal-content {
    background: var(--bg-deep);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
    max-width: 400px;
    width: 90%;
}

[data-theme='light'] .password-modal-content {
    background: var(--bg);
    border-color: rgba(0,0,0,0.1);
    box-shadow: 0 24px 80px rgba(0,0,0,0.15);
}

.password-modal-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.password-modal-content p {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}

.password-modal-content input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: var(--text);
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.2s ease;
}

[data-theme='light'] .password-modal-content input {
    background: rgba(0,0,0,0.05);
    border-color: rgba(0,0,0,0.1);
}

.password-modal-content input:focus {
    border-color: var(--accent);
}

.password-modal-content button {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.password-modal-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.password-error {
    color: #ff6b6b;
    font-size: 0.8rem;
    margin-top: 0.75rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.password-error.visible {
    opacity: 1;
}

/* ── Collapse/Accordion Toggle Button ── */
.disc-toggle-btn {
    position: absolute;
    top: 50%;
    left: 28.88%; /* Matches desktop flex ratio (0.65 / (0.65 + 1.6)) */
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme='light'] .disc-toggle-btn {
    background: rgba(245, 245, 245, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.disc-toggle-btn:hover {
    background: var(--text);
    color: var(--bg-primary);
    transform: translate(-50%, -50%) scale(1.1);
}

.disc-toggle-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Collapsed State Layout */
.book-page.disc-collapsed .disc-section {
    flex: 0 0 0px !important;
    width: 0 !important;
    opacity: 0 !important;
    border-right: none !important;
    pointer-events: none;
}

.book-page.disc-collapsed .disc-toggle-btn {
    left: 24px; /* Move next to screen edge when collapsed */
}

.book-page.disc-collapsed .disc-toggle-btn svg {
    transform: rotate(180deg); /* Flip arrow to point right */
}

@media (max-width: 900px) {
    .disc-toggle-btn {
        display: none !important; /* Hide on mobile/stacked layouts */
    }
}

/* Animations */
.fade-in {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}
