/* ============================================================
   penclo.com - Aurora Library / Diagonal Sections Design
   Colors: #0d0a1a, #1a1528, #00e89d, #0d9b8a, #7b2fbe, #d94f8e, #e8ddd0, #9b8e7e, #ffffff
   Fonts: Commissioner (200-800), Cormorant Garamond (600)
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    background-color: #0d0a1a;
    color: #e8ddd0;
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.4vw, 1.15rem);
    line-height: 1.72;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Aurora Shimmer Background --- */
#aurora-shimmer {
    position: fixed;
    top: 0;
    left: 0;
    width: 200vw;
    height: 200vh;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 30% 20%, rgba(0,232,157,0.05) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 60%, rgba(123,47,190,0.04) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, rgba(217,79,142,0.03) 0%, transparent 50%);
    animation: auroraShimmer 20s ease-in-out infinite;
}

@keyframes auroraShimmer {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-5%, -3%); }
    50% { transform: translate(-8%, -6%); }
    75% { transform: translate(-3%, -2%); }
    100% { transform: translate(0, 0); }
}

/* --- Spine Line --- */
#spine-line {
    position: fixed;
    left: 50%;
    top: 0;
    width: 1px;
    height: 100vh;
    background: linear-gradient(to bottom, #00e89d, #7b2fbe, #d94f8e);
    opacity: 0.15;
    transform: rotate(12deg);
    transform-origin: top center;
    z-index: 1;
    pointer-events: none;
}

/* --- Chapter Navigation (Folio Signatures) --- */
#chapter-nav {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.chapter-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 0.65rem;
    color: #9b8e7e;
    opacity: 0.4;
    text-decoration: none;
    transition: opacity 0.3s ease, color 0.3s ease;
    will-change: transform;
}

.chapter-link.active {
    opacity: 1;
    color: #00e89d;
}

.chapter-link:hover {
    opacity: 0.8;
    color: #e8ddd0;
}

/* --- HERO: The Title Page --- */
#hero {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    overflow: hidden;
    z-index: 2;
}

.hero-text-half {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(0 0, 100% 0, 0 100%);
    background: linear-gradient(168deg, #0d0a1a 0%, #1a0a2e 35%, #0d3d3a 65%, #0d0a1a 100%);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 8vw;
    z-index: 3;
}

.hero-content {
    max-width: 600px;
    position: relative;
    top: -8vh;
}

.hero-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 800;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: -0.02em;
    color: #e8ddd0;
    line-height: 1;
    margin-bottom: 1.2rem;
    opacity: 0;
    transform: translateY(30px);
    animation: heroFadeUp 600ms cubic-bezier(0.34, 1.56, 0.64, 1) 300ms forwards;
}

.hero-subtitle {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 1.4rem;
    color: #9b8e7e;
    opacity: 0;
    transform: translateY(30px);
    animation: heroFadeUp 600ms cubic-bezier(0.34, 1.56, 0.64, 1) 500ms forwards;
}

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

.hero-image-half {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
    overflow: hidden;
    z-index: 2;
}

.hero-image-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(168deg, rgba(13,155,138,0.25) 0%, rgba(123,47,190,0.25) 100%);
    mix-blend-mode: color;
    z-index: 1;
    pointer-events: none;
}

.hero-diagonal-seam {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(168deg, transparent 47%, rgba(13,10,26,0.6) 49%, rgba(13,10,26,0.6) 51%, transparent 53%);
    z-index: 4;
    pointer-events: none;
}

/* --- Chapter Sections --- */
.chapter {
    position: relative;
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    min-height: 80vh;
    padding: 120px 0;
    z-index: 2;
    overflow: hidden;
}

.chapter::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(12deg, rgba(0,232,157,0.04) 0%, rgba(123,47,190,0.04) 100%);
    pointer-events: none;
}

/* Recto (right-page) sections: skew clockwise */
.chapter.recto {
    transform: skewY(-3deg);
}

.chapter.recto > * {
    transform: skewY(3deg);
}

/* Verso (left-page) sections: skew counterclockwise */
.chapter.verso {
    transform: skewY(3deg);
}

.chapter.verso > * {
    transform: skewY(-3deg);
}

/* Spine separator between sections */
.chapter + .chapter::after {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    width: 1px;
    height: 120px;
    background: linear-gradient(to bottom, transparent, #0d4a3a, transparent);
    opacity: 0.3;
}

/* --- Chapter Watermark --- */
.chapter-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(4rem, 12vw, 10rem);
    color: #e8ddd0;
    opacity: 0.06;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}

/* --- Page Turn Corner --- */
.page-turn-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 40px;
    height: 40px;
    z-index: 10;
    cursor: pointer;
    overflow: hidden;
}

.page-turn-corner::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 40px 40px 0;
    border-color: transparent #221d35 transparent transparent;
    filter: drop-shadow(-2px 2px 3px rgba(0,0,0,0.3));
    transition: border-width 200ms ease-out;
}

.page-turn-corner:hover::before {
    border-width: 0 60px 60px 0;
}

/* --- Marginalia --- */
.marginalia-left,
.marginalia-right {
    padding: 40px 12px;
    display: flex;
    align-items: flex-start;
}

.marginalia-left {
    grid-column: 1;
    justify-content: flex-end;
    text-align: right;
    border-color: #ffffff; /* marginalia strip base color per design */
}

.marginalia-right {
    grid-column: 3;
    justify-content: flex-start;
    text-align: left;
}

.marginalia-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 600;
    font-style: italic;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    line-height: 1.5;
    color: #d94f8e;
    border-left: 2px solid #d94f8e;
    padding-left: 8px;
    opacity: 0.8;
}

.marginalia-annotation {
    font-family: 'Commissioner', sans-serif;
    font-weight: 200;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    line-height: 1.5;
    color: rgba(61,139,122,0.6);
    font-feature-settings: 'onum' 1;
}

/* --- Chapter Content --- */
.chapter-content {
    grid-column: 2;
    max-width: 720px;
    padding: 0 40px;
    position: relative;
}

.recto .chapter-content {
    margin-left: auto;
    text-align: right;
}

.verso .chapter-content {
    margin-right: auto;
    text-align: left;
}

/* --- Bookmark Ribbon --- */
.bookmark-ribbon {
    position: absolute;
    top: 0;
    left: -20px;
    width: 3px;
    height: 40px;
    background-color: #d94f8e;
    opacity: 0.7;
}

.recto .bookmark-ribbon {
    left: auto;
    right: -20px;
}

/* --- Chapter Heading --- */
.chapter-heading {
    font-family: 'Commissioner', sans-serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    letter-spacing: -0.02em;
    color: #e8ddd0;
    margin-bottom: 1.5em;
    transition: font-weight 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform;
}

.chapter-heading:hover {
    font-weight: 700;
}

/* --- Chapter Body Text --- */
.chapter-body {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: clamp(1rem, 1.4vw, 1.15rem);
    line-height: 1.72;
    color: #e8ddd0;
    margin-bottom: 1.5em;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.chapter-body + .chapter-body {
    text-indent: 2em;
}

.first-paragraph {
    text-indent: 0 !important;
}

.first-paragraph::first-letter {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 3.5em;
    float: left;
    line-height: 0.8;
    padding-right: 0.1em;
    padding-top: 0.05em;
    color: #00e89d;
}

/* --- Folio Signature --- */
.folio-signature {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 0.65rem;
    color: #9b8e7e;
    opacity: 0.4;
    letter-spacing: 0.1em;
}

/* --- Section Reveal Animation --- */
.chapter-content,
.marginalia-left,
.marginalia-right,
.chapter-watermark {
    opacity: 0;
    transition: opacity 600ms ease;
}

.chapter.revealed .chapter-content {
    opacity: 1;
    transition-delay: 120ms;
}

.chapter.revealed .chapter-watermark {
    opacity: 0.06;
    transition-delay: 0ms;
}

.chapter.revealed .marginalia-left {
    opacity: 1;
    transition-delay: 300ms;
}

.chapter.revealed .marginalia-right {
    opacity: 1;
    transition-delay: 360ms;
}

/* --- Diagonal Wipe Reveal --- */
.chapter.recto {
    clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
    transition: clip-path 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chapter.recto.revealed {
    clip-path: polygon(0 0, 120% 0, 120% 100%, 0 100%);
}

.chapter.verso {
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
    transition: clip-path 800ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.chapter.verso.revealed {
    clip-path: polygon(-20% 0, 100% 0, 100% 100%, -20% 100%);
}

/* --- COLOPHON --- */
#colophon {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 120px 40px;
    text-align: center;
    z-index: 2;
}

.colophon-content {
    max-width: 400px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms ease, transform 800ms ease;
}

#colophon.revealed .colophon-content {
    opacity: 1;
    transform: translateY(0);
}

.colophon-ornament {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
}

.colophon-mark {
    width: 60px;
    height: 60px;
}

.colophon-title {
    font-family: 'Commissioner', sans-serif;
    font-weight: 700;
    font-size: 1.6rem;
    letter-spacing: -0.02em;
    color: #e8ddd0;
    margin-bottom: 1.5rem;
}

.colophon-text {
    font-family: 'Commissioner', sans-serif;
    font-weight: 300;
    font-size: 0.9rem;
    color: #9b8e7e;
    line-height: 1.8;
}

.colophon-separator {
    width: 40px;
    height: 1px;
    background: linear-gradient(to right, #00e89d, #7b2fbe);
    margin: 1.5rem auto;
    opacity: 0.4;
}

.colophon-signature {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 0.85rem;
    color: #9b8e7e;
    opacity: 0.5;
    letter-spacing: 0.2em;
}

/* --- Magnetic Element Base --- */
.magnetic-element {
    will-change: transform;
    transition: transform 0.1s ease-out;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .chapter {
        grid-template-columns: 20px 1fr 20px;
        padding: 80px 0;
    }

    .marginalia-left,
    .marginalia-right {
        display: none;
    }

    .chapter-content {
        grid-column: 1 / -1;
        padding: 0 24px;
    }

    .recto .chapter-content,
    .verso .chapter-content {
        margin: 0;
        text-align: left;
    }

    .chapter.recto,
    .chapter.verso {
        transform: skewY(0deg);
    }

    .chapter.recto > *,
    .chapter.verso > * {
        transform: skewY(0deg);
    }

    #chapter-nav {
        right: 8px;
    }

    .chapter-link {
        width: 22px;
        height: 22px;
        font-size: 0.55rem;
    }

    .hero-content {
        padding-right: 20px;
    }

    .hero-title {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }

    .bookmark-ribbon {
        left: 4px !important;
        right: auto !important;
    }
}

@media (max-width: 480px) {
    .hero-text-half {
        clip-path: polygon(0 0, 100% 0, 100% 60%, 0 80%);
    }

    .hero-image-half {
        clip-path: polygon(0 80%, 100% 60%, 100% 100%, 0 100%);
    }

    .hero-content {
        top: -15vh;
    }

    .colophon-content {
        padding: 0 20px;
    }
}

/* --- Selection --- */
::selection {
    background-color: rgba(0,232,157,0.2);
    color: #e8ddd0;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: #0d0a1a;
}

::-webkit-scrollbar-thumb {
    background: #221d35;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3d8b7a;
}
