/* ============================================
   ACHIEVEMENTS SYSTEM
   ============================================ */

/* === NOTEBOOK PAGE TABS === */
.notebook-tabs {
    position: absolute;
    top: 80px;
    right: -58px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    z-index: 4;
    /* Keep container low in stack */
}

.notebook-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    background:
        url('../img/parchment_bg.png') center/cover,
        linear-gradient(to right, #c5b498 0%, #dcd0bc 100%);
    background-blend-mode: overlay, normal;
    border: 1px solid rgba(92, 61, 30, 0.5);
    /* Subtle leather border */
    border-left: none;
    border-radius: 0 6px 6px 0;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ink-faded);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    transform: translateX(-6px);
    /* Peak out slightly more to show label */
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
    /* Etched text effect */
    box-shadow:
        inset 1px 0 2px rgba(255, 255, 255, 0.3),
        /* Edge highlight */
        inset -1px 0 4px rgba(0, 0, 0, 0.05),
        /* Inner shadow */
        1px 1px 3px rgba(0, 0, 0, 0.15);
    /* Drop shadow */
    writing-mode: vertical-rl;
    text-orientation: mixed;
    opacity: 0.95;
    z-index: 1;
    pointer-events: auto;
}

.notebook-tab svg {
    width: 20px;
    height: 20px;
    opacity: 0.6;
    flex-shrink: 0;
    transform: rotate(90deg);
}

.notebook-tab:hover {
    background:
        url('../img/parchment_bg.png') center/cover,
        linear-gradient(to right, #ece2d0 0%, #e6dbc7 100%);
    background-blend-mode: overlay, normal;
    color: var(--ink-brown);
    transform: translateX(0) rotate(2deg);
    /* Slide out and subtle roll */
    opacity: 1;
    z-index: 100;
    box-shadow:
        inset 1px 0 2px rgba(255, 255, 255, 0.5),
        2px 2px 8px rgba(0, 0, 0, 0.15);
}

.notebook-tab:hover svg {
    opacity: 0.8;
}

.notebook-tab.active {
    /* Use exact parchment color to match page */
    background:
        url('../img/parchment_bg.png') center/cover,
        linear-gradient(to right, #d6cab0 0%, #d6cab0 100%);
    background-blend-mode: multiply, normal;

    color: var(--ink-brown);
    border: 1px solid transparent;

    /* Borders only on outer edges - remove left border entirely */
    border-right: 1px solid rgba(92, 61, 30, 0.4);
    border-top: 1px solid rgba(92, 61, 30, 0.3);
    border-bottom: 1px solid rgba(92, 61, 30, 0.3);

    /* Page-stack depth: highlight on top, shadow on right edge */
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.4),
        /* Top edge rim light */
        inset -2px 0 5px rgba(0, 0, 0, 0.05),
        /* Right edge shadow */
        3px 2px 6px rgba(0, 0, 0, 0.15);
    /* Subtle drop shadow for depth */

    /* Reduced shift to a more subtle balance */
    transform: translateX(4px);
    opacity: 1;
    z-index: 1500;
    pointer-events: none;
    padding-left: 20px;

    /* Organic torn-edge vibe */
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

/* Seam concealer with texture match - the "bridge" between tab and page */
.notebook-tab.active::before {
    content: '';
    position: absolute;
    top: -1px;
    /* Cover border too */
    bottom: -1px;
    left: -20px;
    /* Overlap the book edge sufficiently */
    width: 32px;
    background: url('../img/parchment_bg.png') center/cover;
    /* Sharper mask: starts transparent but quickly becomes opaque to hide artifacts */
    mask-image: linear-gradient(to right, transparent 0%, black 25%, black 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 25%, black 100%);
    z-index: 2;
    pointer-events: none;
}

.notebook-tab.active svg {
    opacity: 1;
    color: var(--gold-dark);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

/* === NOTEBOOK PAGES === */
.notebook-page {
    display: none;
    opacity: 0;
    position: relative;
    z-index: 10;
    /* Page is above inactive tabs (z-index 1) but below active (z-index 20) */
    background: var(--parchment);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    animation: pageFlipIn 0.4s ease forwards;
    min-height: 840px;
    /* Synchronized with Battle page average height */
}

.notebook-page.active {
    display: block;
    opacity: 1;
}

@keyframes pageFlipIn {
    0% {
        opacity: 0;
        transform: rotateY(-5deg) translateX(-10px);
    }

    100% {
        opacity: 1;
        transform: rotateY(0) translateX(0);
    }
}

/* === ACHIEVEMENTS PAGE CONTENT === */
.achievements-page-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 840px;
    position: relative;
    padding: 0;
    background: none;
    box-shadow: none;
    overflow: visible;
}

.achievements-left-panel,
.achievements-right-panel {
    background:
        url('../img/parchment_bg.png') center/cover,
        linear-gradient(160deg, var(--parchment-light) 0%, var(--parchment) 100%);
    background-blend-mode: multiply, normal;
    padding: var(--space-6) var(--space-5);
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.achievements-left-panel {
    border-right: 1px solid var(--parchment-shadow);
    box-shadow: inset -8px 0 12px -8px rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    justify-content: center;
    align-items: center;
}

.achievements-right-panel {
    box-shadow: inset 8px 0 12px -8px rgba(0, 0, 0, 0.05);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Central Spine / Binding Thread - EXACTLY like on battle page */
.achievements-spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
    background: rgba(0, 0, 0, 0.1);
    border-left: 1px dashed rgba(255, 255, 255, 0.2);
    z-index: 21;
    pointer-events: none;
}

.achievements-page-header {
    text-align: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--leather-light);
    flex-shrink: 0;
}

.achievements-page-title {
    font-family: var(--font-display);
    font-size: 1.8rem;
    color: var(--ink-brown);
    margin: 0 0 var(--space-2);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.achievements-page-subtitle {
    font-family: 'IM Fell English', serif;
    font-size: 1rem;
    font-style: italic;
    color: var(--ink-faded);
    margin: 0;
}

.achievements-page-grid {
    flex: 1;
    overflow-y: auto;
    padding-right: var(--space-2);
    /* Custom scrollbar styling support could be added here */
}

/* === NOTIFICATION CONTAINER === */
.achievement-notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 25000;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    pointer-events: none;
}

/* === NOTIFICATION POPUP === */
.achievement-notification {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    min-width: 320px;
    max-width: 400px;

    /* Parchment background */
    background:
        url('../img/parchment_bg.png') center/cover,
        linear-gradient(170deg, #f5ebe0 0%, #e8dcc8 50%, #ddd0b8 100%);
    background-blend-mode: multiply, normal;

    border-radius: var(--radius-lg);

    /* Layered shadows */
    box-shadow:
        0 0 30px rgba(212, 168, 75, 0.5),
        0 0 60px rgba(212, 168, 75, 0.2),
        2px 3px 0 rgba(92, 61, 30, 0.4),
        0 10px 30px rgba(0, 0, 0, 0.35),
        inset 0 0 30px rgba(139, 90, 43, 0.08),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);

    animation: achievementSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    overflow: hidden;
}

/* Decorative inner border */
.achievement-notification::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 2px solid var(--gold-ornament);
    border-radius: calc(var(--radius-lg) - 4px);
    pointer-events: none;
    opacity: 0.6;
}

/* Background glow effect */
.achievement-notification-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    opacity: 0.8;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

/* Icon container */
.achievement-notification-icon {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 168, 75, 0.15);
    border: 3px solid var(--gold-ornament);
    border-radius: var(--radius-md);
    box-shadow:
        0 0 15px rgba(212, 168, 75, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    animation: iconPulse 2s ease-in-out infinite;
}

.achievement-notification-icon svg {
    width: 26px;
    height: 26px;
    color: var(--gold-dark);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

@keyframes iconPulse {

    0%,
    100% {
        box-shadow:
            0 0 15px rgba(212, 168, 75, 0.3),
            inset 0 2px 4px rgba(255, 255, 255, 0.2);
    }

    50% {
        box-shadow:
            0 0 25px rgba(212, 168, 75, 0.5),
            0 0 40px rgba(212, 168, 75, 0.2),
            inset 0 2px 4px rgba(255, 255, 255, 0.3);
    }
}

/* Content */
.achievement-notification-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.achievement-notification-header {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gold-dark);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.achievement-notification-name {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink-brown);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.achievement-notification-desc {
    font-family: 'IM Fell English', serif;
    font-size: 0.85rem;
    font-style: italic;
    color: var(--ink-faded);
    line-height: 1.3;
}

/* Slide in animation */
@keyframes achievementSlideIn {
    0% {
        opacity: 0;
        transform: translateX(100%) scale(0.8);
    }

    60% {
        opacity: 1;
        transform: translateX(-10px) scale(1.02);
    }

    80% {
        transform: translateX(5px) scale(0.99);
    }

    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Fade out animation */
.achievement-notification.fade-out {
    animation: achievementFadeOut 0.5s ease-in forwards;
}

@keyframes achievementFadeOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateX(50px) scale(0.9);
    }
}


/* ============================================
   ACHIEVEMENTS GRID (used in page)
   ============================================ */

.achievements-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-3);
    margin-bottom: var(--space-4);
    background: rgba(212, 168, 75, 0.1);
    border: 2px solid var(--gold-ornament);
    border-radius: var(--radius-md);
}

.achievements-count {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold-dark);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.achievements-label {
    font-family: 'IM Fell English', serif;
    font-size: 0.8rem;
    color: var(--ink-faded);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.achievements-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.achievements-category {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.achievements-category-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--leather);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding-bottom: var(--space-1);
    border-bottom: 1px dashed var(--leather-light);
}

.achievements-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--space-3);
    padding-bottom: var(--space-2);
    justify-items: center;
}

/* Individual achievement item - larger for page view */
.achievement-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: var(--space-3);
    width: 90px;
    background: rgba(139, 90, 43, 0.05);
    border: 2px solid var(--leather-light);
    border-radius: var(--radius-md);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    cursor: help;
}

.achievement-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.achievement-item.locked {
    opacity: 0.4;
    filter: grayscale(1);
    border: 1px dashed var(--parchment-shadow);
    background: rgba(0, 0, 0, 0.02);
}

.achievement-item.locked:hover {
    opacity: 0.6;
    border-style: solid;
    border-color: var(--leather-light);
}

.achievement-item.unlocked {
    background: rgba(212, 168, 75, 0.12);
    border-color: var(--gold-ornament);
}

.achievement-item.unlocked:hover {
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.15),
        0 0 25px rgba(212, 168, 75, 0.3);
}

.achievement-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid var(--leather-light);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.achievement-icon svg {
    width: 24px;
    height: 24px;
    color: var(--ink-faded);
}

.achievement-item.unlocked .achievement-icon svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.achievement-name {
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--ink-brown);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
}

.achievement-check {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--gold-highlight) 0%, var(--gold-ornament) 100%);
    color: var(--ink-black);
    font-size: 0.65rem;
    font-weight: 900;
    border-radius: 50%;
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid var(--gold-dark);
}

/* === ACHIEVEMENT TOOLTIP TWEAKS === */
.achievement-tooltip .tooltip-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.achievement-tooltip .tooltip-status {
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.achievement-tooltip .tooltip-icon {
    filter: none !important;
}


.achievement-tooltip .tooltip-description {
    font-family: 'IM Fell English', serif;
    font-size: 1rem;
    color: var(--ink-brown);
    padding: 10px;
    background: rgba(139, 90, 43, 0.04);
    border-radius: 4px;
    border: 1px dashed rgba(139, 90, 43, 0.1);
}

.achievement-tooltip.locked {
    filter: grayscale(0.85);
    opacity: 0.95;
}

.achievement-tooltip.locked .tooltip-header {
    border-bottom-color: var(--parchment-shadow) !important;
}

.achievement-tooltip.locked .tooltip-icon {
    color: var(--ink-faded) !important;
    opacity: 0.6;
}

.achievement-tooltip.locked .tooltip-type {
    background: rgba(0, 0, 0, 0.05) !important;
    color: var(--ink-faded) !important;
    border-color: var(--parchment-shadow) !important;
}