/* Base Styles */
:root {
    --light-blue: #cfe8f6;
    --primary-color: #0a0a0a;
    --secondary-color: #1a1a1a;
    --accent-color: #e63946;
    --text-color: #1b2b3a;
    --muted-text: #3a4d5c;
    --card-bg: rgba(255, 255, 255, 0.62);
    --bg-color: var(--light-blue);
    --nav-font: 'Rajdhani', sans-serif;
    --body-font: 'Montserrat', sans-serif;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --spacing-xl: 4rem;
    --transition: all 0.3s ease;
}

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

body {
    font-family: var(--body-font);
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    overflow-x: hidden;
    letter-spacing: 0.01em;
    font-size: 1rem;
}

a {
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-color);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--nav-font);
    margin-bottom: var(--spacing-md);
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: var(--spacing-lg);
}

.section-link {
    color: inherit;
    text-decoration: none;
}

.section-link:hover {
    color: var(--accent-color);
}

/* Navigation */
.main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: var(--spacing-md) 0;
    background-color: var(--light-blue);
    transition: var(--transition);
    z-index: 100;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
    font-family: var(--nav-font);
    font-weight: 600;
    letter-spacing: 0.06em;
}

.logo {
    font-family: var(--nav-font);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.nav-links a {
    color: var(--text-color);
    font-family: var(--nav-font);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    opacity: 0.85;
    transition: var(--transition);
}

.nav-links a:hover {
    opacity: 1;
    color: var(--accent-color);
}

.main-nav.scrolled {
    background-color: var(--light-blue);
    padding: 0.5rem 0;
    box-shadow: 0 2px 10px rgba(27, 43, 58, 0.12);
}

/* Content */
.content {
    position: relative;
    z-index: 2;
    padding-top: 5rem;
}

.section {
    padding: var(--spacing-xl) var(--spacing-lg);
    max-width: 1200px;
    margin: 0 auto;
    scroll-margin-top: 5rem;
}

.fade-in {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.fade-in.visible {
    opacity: 1;
}

/* Bookshelf */
.books-section {
    max-width: 1200px;
}

.bookshelf {
    position: relative;
    perspective: 1400px;
}

.bookshelf-rail {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 0.75rem 6rem 0.35rem 0;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
}

.bookshelf-board {
    height: 18px;
    border-radius: 2px 2px 6px 6px;
    background:
        linear-gradient(180deg, #c08958 0%, #8d5a32 42%, #6d4224 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        0 10px 18px rgba(27, 43, 58, 0.18);
}

.book {
    --pages: 250;
    --spine-width: clamp(1.5rem, calc(1.05rem + (var(--pages) * 0.12px)), 4.4rem);
    --cover-width: 10.25rem;
    --spine-color: #31415c;
    --cover-color: #d7e6f3;
    --book-height: 13.75rem;
    position: relative;
    flex: 0 0 var(--spine-width);
    width: var(--spine-width);
    height: var(--book-height);
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transform-style: preserve-3d;
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x;
    transition: flex-basis 0.45s cubic-bezier(0.22, 1, 0.36, 1),
                width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.book:focus-visible {
    outline: 2px solid var(--text-color);
    outline-offset: 4px;
}

.book-3d {
    display: block;
    position: relative;
    width: var(--spine-width);
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: left center;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.book-spine,
.book-cover,
.book-page-edge {
    display: block;
    position: absolute;
    top: 0;
    backface-visibility: hidden;
}

.book-spine {
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 0.15rem;
    color: #f4f0e8;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.12)),
        var(--spine-color);
    box-shadow:
        inset 1px 0 0 rgba(255, 255, 255, 0.12),
        inset -1px 0 0 rgba(0, 0, 0, 0.25);
}

.book-spine-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-family: var(--nav-font);
    font-size: clamp(0.7rem, calc(var(--spine-width) * 0.42), 0.95rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1;
    max-height: 100%;
    overflow: hidden;
    white-space: nowrap;
}

.book-cover {
    left: 0;
    width: var(--cover-width);
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1rem 0.85rem;
    color: var(--text-color);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.12)),
        var(--cover-color);
    transform: rotateY(-90deg);
    transform-origin: left center;
    box-shadow: 8px 10px 20px rgba(27, 43, 58, 0.22);
}

.book-cover.has-image {
    padding: 0;
    overflow: hidden;
}

.book-cover.has-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-cover-title {
    font-family: var(--nav-font);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.15;
    margin-bottom: 0.3rem;
}

.book-cover-author,
.book-cover-pages {
    font-size: 0.75rem;
    color: var(--muted-text);
}

.book-page-edge {
    left: 100%;
    width: 10px;
    height: 100%;
    background: repeating-linear-gradient(
        to right,
        #f7f3ea 0 1px,
        #e5dece 1px 2px
    );
    transform: rotateY(90deg);
    transform-origin: left center;
}

.book.is-pulled {
    z-index: 5;
    flex-basis: var(--cover-width);
    width: var(--cover-width);
}

.book.is-pulled .book-3d {
    transform: rotateY(90deg);
}

@media (hover: hover) and (pointer: fine) {
    .book:hover {
        z-index: 5;
        flex-basis: var(--cover-width);
        width: var(--cover-width);
    }

    .book:hover .book-3d {
        transform: rotateY(90deg);
    }
}

[hidden] {
    display: none !important;
}

.book-page {
    padding-bottom: var(--spacing-xl);
}

.book-detail {
    max-width: 760px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
}

.book-detail-header {
    margin-bottom: var(--spacing-xl);
}

.book-back {
    display: inline-block;
    position: relative;
    font-family: var(--nav-font);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--muted-text);
    margin-bottom: 1.1rem;
    text-decoration: none;
}

.book-back::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.08em;
    height: 1px;
    background: currentColor;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

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

.book-back:hover::after {
    opacity: 1;
}

.book-detail-header h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    letter-spacing: 0.03em;
    margin-bottom: 0.6rem;
}

.book-detail-author {
    font-family: var(--nav-font);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.book-detail-pages {
    color: var(--muted-text);
    margin-bottom: 0.85rem;
}

.star-rating {
    --rating: 0;
    position: relative;
    display: inline-block;
    font-size: 1.7rem;
    letter-spacing: 0.12em;
    line-height: 1;
}

.stars-empty {
    color: rgba(27, 43, 58, 0.2);
}

.stars-filled {
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    white-space: nowrap;
    color: #d4a017;
    width: calc(var(--rating) / 5 * 100%);
}

.book-detail-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 8px 20px rgba(27, 43, 58, 0.08);
}

.book-detail-section h2 {
    font-size: 1.35rem;
    margin-bottom: 0.85rem;
}

.book-detail-section p,
.book-detail-section li {
    color: var(--muted-text);
    font-size: 1rem;
    line-height: 1.7;
}

.book-quotes {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.book-quotes li {
    border-left: 3px solid var(--accent-color);
    padding-left: 1rem;
    font-style: italic;
}

.book-empty {
    color: var(--muted-text);
    font-style: italic;
}

/* Notebook notes */
.notes-section {
    max-width: 1200px;
}

.notes-desk {
    position: relative;
}

.notes-rail {
    display: flex;
    align-items: flex-end;
    gap: 1.75rem;
    overflow-x: auto;
    overflow-y: visible;
    padding: 1.75rem 1rem 2rem 0.35rem;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
}

.note-leaf {
    --note-width: 15.4rem;
    --note-height: 20rem;
    --tilt: -2deg;
    --paper: #f6efe2;
    --rule: #9eb8cc;
    --margin: #d97b7b;
    appearance: none;
    flex: 0 0 var(--note-width);
    width: var(--note-width);
    height: var(--note-height);
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    transform: rotate(var(--tilt));
    transform-origin: 50% 88%;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-x;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.note-leaf:focus-visible {
    outline: 2px solid var(--text-color);
    outline-offset: 8px;
}

.note-sheet {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    padding: 1.45rem 1.05rem 2.55rem 2.15rem;
    color: #2a3540;
    text-align: left;
    background:
        radial-gradient(circle at 1.2rem 2rem, #efe6d4 0 0.32rem, transparent 0.34rem),
        radial-gradient(circle at 1.2rem 5.4rem, #efe6d4 0 0.32rem, transparent 0.34rem),
        radial-gradient(circle at 1.2rem 8.8rem, #efe6d4 0 0.32rem, transparent 0.34rem),
        radial-gradient(circle at 1.2rem 12.2rem, #efe6d4 0 0.32rem, transparent 0.34rem),
        radial-gradient(circle at 1.2rem 15.6rem, #efe6d4 0 0.32rem, transparent 0.34rem),
        radial-gradient(circle at 1.2rem 19rem, #efe6d4 0 0.32rem, transparent 0.34rem),
        linear-gradient(90deg, transparent 1.85rem, var(--margin) 1.85rem, var(--margin) 1.96rem, transparent 1.96rem),
        repeating-linear-gradient(
            transparent 0,
            transparent 1.7rem,
            var(--rule) 1.7rem,
            var(--rule) calc(1.7rem + 1px)
        ),
        linear-gradient(180deg, #fbf6ec 0%, var(--paper) 55%, #efe4d0 100%);
    clip-path: polygon(
        1.8% 0%, 3.4% 2.6%, 0.8% 6.4%, 3.8% 10.2%, 0.6% 14.8%,
        3.2% 19%, 1% 24%, 3.6% 29.4%, 0.4% 35%, 3.4% 40.6%,
        1.2% 46.2%, 3.8% 52%, 0.7% 58%, 3.5% 64.2%, 1.1% 70.4%,
        3.6% 76.6%, 0.5% 83%, 3.3% 89.2%, 1.4% 95%, 2.2% 100%,
        100% 100%, 100% 0%
    );
    filter: drop-shadow(0 12px 16px rgba(27, 43, 58, 0.16));
}

.note-leaf:nth-child(3n + 2) .note-sheet {
    clip-path: polygon(
        2.4% 0%, 0.6% 3.2%, 3.6% 7.1%, 0.9% 12%, 3.2% 17.4%,
        0.4% 22.8%, 3.8% 28%, 1.1% 33.6%, 3.4% 39.2%, 0.7% 45%,
        3.6% 51%, 1% 57.2%, 3.2% 63.4%, 0.5% 69.6%, 3.8% 75.8%,
        1.2% 82%, 3.5% 88.4%, 0.8% 94%, 2% 100%,
        100% 100%, 100% 0%
    );
}

.note-leaf:nth-child(3n + 3) .note-sheet {
    clip-path: polygon(
        0.6% 0%, 3.2% 3.8%, 1.2% 8.2%, 3.8% 13.6%, 0.4% 18.8%,
        3.4% 24.6%, 0.9% 30.4%, 3.6% 36%, 1.1% 42.2%, 0.5% 48.6%,
        3.5% 54.4%, 1% 60.8%, 3.8% 67%, 0.6% 73.4%, 3.2% 79.6%,
        1.4% 86%, 3.6% 92.2%, 0.8% 97.2%, 1.8% 100%,
        100% 100%, 100% 0%
    );
}

.note-holes {
    position: absolute;
    inset: 0 auto 0 0.86rem;
    width: 0.72rem;
    background:
        radial-gradient(circle, rgba(27, 43, 58, 0.18) 0 0.13rem, transparent 0.14rem) 50% 2rem / 100% 3.4rem,
        radial-gradient(circle at 50% 50%, #cfe8f6 0 0.24rem, transparent 0.26rem) 50% 2rem / 100% 3.4rem;
    background-repeat: repeat-y;
    pointer-events: none;
}

.note-title,
.note-body {
    display: block;
    position: relative;
    font-family: 'Caveat', cursive;
    line-height: 1.7rem;
}

.note-date {
    position: absolute;
    right: 1.05rem;
    bottom: 0.7rem;
    font-family: 'Caveat', cursive;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.7rem;
    color: #6a7b88;
    text-align: right;
}

.note-title {
    font-size: 1.85rem;
    font-weight: 700;
    margin-bottom: 1.7rem;
}

.note-body {
    font-size: 1.28rem;
    font-weight: 500;
    color: #3b4a57;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-leaf.is-pulled {
    z-index: 5;
    transform: translateY(-12px) rotate(0deg);
}

@media (hover: hover) and (pointer: fine) {
    .note-leaf:hover {
        z-index: 5;
        transform: translateY(-12px) rotate(0deg);
    }
}

.notes-index-page {
    padding-bottom: var(--spacing-xl);
}

.notes-index {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
}

.notes-index-header {
    margin-bottom: var(--spacing-xl);
}

.notes-index-header .book-back {
    display: inline-block;
}

.notes-index-header h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    letter-spacing: 0.03em;
    margin-bottom: 0;
    text-align: center;
}

.notes-month {
    margin-bottom: 2.75rem;
}

.notes-month h2 {
    font-size: 1.35rem;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.notes-month-list {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 2rem 1.75rem;
    overflow: visible;
    padding: 1.5rem 0.35rem 1.25rem;
}

.notes-month-list .note-leaf {
    touch-action: manipulation;
}

.note-page {
    padding-bottom: var(--spacing-xl);
}

.note-detail {
    max-width: 760px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
}

.note-detail-date {
    color: var(--muted-text);
    margin-bottom: 0.85rem;
}

.note-prose > * + * {
    margin-top: 1rem;
}

.note-prose h2,
.note-prose h3 {
    font-size: 1.35rem;
    margin-bottom: 0;
}

.note-prose ul,
.note-prose ol {
    padding-left: 1.25rem;
    color: var(--muted-text);
}

.note-prose code {
    font-size: 0.92em;
    background: rgba(27, 43, 58, 0.08);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

.note-prose pre {
    overflow-x: auto;
    background: rgba(27, 43, 58, 0.08);
    padding: 1rem 1.1rem;
    border-radius: 8px;
}

.note-prose pre code {
    background: transparent;
    padding: 0;
}

.note-prose blockquote {
    border-left: 3px solid var(--accent-color);
    padding-left: 1rem;
    color: var(--muted-text);
    font-style: italic;
}

.note-prose a {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

@media (prefers-reduced-motion: reduce) {
    .book-3d,
    .note-leaf {
        transition: none;
    }
}
