/* ============================================
   rinji.net - Mcbling Scholarly Notebook
   Palette: Sepia-Nostalgic
   Fonts: Caveat, Nunito, Kalam
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --aged-parchment: #F5EDDF;
    --warm-vellum: #EDE3D0;
    --dark-walnut: #3B2F2F;
    --ink-brown: #4A3C32;
    --burnished-gold: #B8923F;
    --margin-red: #C4826A;
    --dusty-rose: #C9918B;
    --espresso: #2C221B;
    --champagne-glint: #E8D5A3;
    --subtle-border: #D5C9B5;
    --success-green: #7A9E7E;
    --caution-amber: #D4A94C;
    --skeleton-color: #D4C4A8;
}

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

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

body {
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    color: var(--ink-brown);
    background-color: var(--aged-parchment);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 8px,
        rgba(184, 146, 63, 0.04) 8px,
        rgba(184, 146, 63, 0.04) 9px
    );
    line-height: 1.72;
    letter-spacing: 0.015em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Caveat', cursive;
    color: var(--dark-walnut);
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.section-heading {
    font-size: clamp(1.6rem, 3.5vw, 2.8rem);
    font-weight: 700;
    margin-bottom: 1.2rem;
    position: relative;
    display: inline-block;
}

/* Sparkle stars near headings */
.section-heading::after {
    content: '';
    position: absolute;
    top: -4px;
    right: -18px;
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 0 L7 4.5 L12 6 L7 7.5 L6 12 L5 7.5 L0 6 L5 4.5 Z' fill='%23B8923F'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    mix-blend-mode: screen;
    opacity: 0.8;
}

.section-heading::before {
    content: '';
    position: absolute;
    top: 8px;
    right: -30px;
    width: 8px;
    height: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 0 L7 4.5 L12 6 L7 7.5 L6 12 L5 7.5 L0 6 L5 4.5 Z' fill='%23B8923F'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    mix-blend-mode: screen;
    opacity: 0.5;
}

p {
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    margin-bottom: 1rem;
    max-width: 52rem;
}

/* --- Margin Line --- */
.margin-line {
    position: fixed;
    left: 3rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: var(--margin-red);
    opacity: 0.3;
    z-index: 10;
    pointer-events: none;
}

@media (max-width: 768px) {
    .margin-line {
        display: none;
    }
}

/* --- Margin Notes --- */
.margin-note {
    position: absolute;
    left: -5.5rem;
    width: 4.5rem;
    text-align: right;
}

@media (min-width: 769px) {
    .margin-note {
        position: sticky;
        top: 40vh;
        float: left;
        margin-left: -6rem;
        margin-right: 1.5rem;
        width: 4.5rem;
        z-index: 5;
    }
}

.margin-note-text {
    font-family: 'Kalam', cursive;
    font-size: 0.85rem;
    color: var(--margin-red);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: inline-block;
    padding: 0.3rem 0.15rem;
}

.margin-note-text:hover {
    transform: rotate(180deg) scale(1.05);
    box-shadow: 0 2px 12px rgba(184, 146, 63, 0.15);
}

@media (max-width: 768px) {
    .margin-note {
        position: relative;
        left: 0;
        float: none;
        margin: 0 0 1rem 0;
        width: auto;
        background: var(--warm-vellum);
        border-left: 2px solid var(--margin-red);
        border-radius: 4px;
        padding: 0.5rem 0.75rem;
        transform: rotate(-1deg);
    }

    .margin-note-text {
        writing-mode: horizontal-tb;
        text-orientation: initial;
        transform: none;
    }

    .margin-note-text:hover {
        transform: scale(1.05);
    }
}

/* --- Hero Folio --- */
.hero-folio {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.hero-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.8s ease;
    z-index: 0;
}

.hero-canvas.visible {
    opacity: 0.15;
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0 1.5rem;
}

.title-svg {
    width: clamp(280px, 60vw, 600px);
    height: auto;
    overflow: visible;
}

.title-text-path {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 80px;
    fill: none;
    stroke: var(--dark-walnut);
    stroke-width: 1.5;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: fill 0.3s ease;
}

.title-text-path.drawn {
    stroke-dashoffset: 0;
    fill: var(--dark-walnut);
}

.hero-tagline {
    font-family: 'Nunito', sans-serif;
    font-weight: 300;
    font-size: 1.1rem;
    color: var(--ink-brown);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    margin-top: 0.75rem;
}

.hero-tagline.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-indicator {
    position: absolute;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.scroll-arrow {
    animation: gentleBob 2s ease-in-out infinite;
}

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

/* --- Content Sections --- */
.content-section {
    position: relative;
    display: grid;
    grid-template-columns: minmax(1.5rem, 1fr) minmax(auto, 52rem) minmax(1.5rem, 1fr);
    padding: 4rem 0;
    transition: transform 0.3s ease;
}

.content-section .section-skeleton,
.content-section .section-content {
    grid-column: 2 / 3;
}

.content-section .section-content {
    position: relative;
    padding-left: 1rem;
}

@media (min-width: 769px) {
    .content-section .section-content {
        padding-left: 2rem;
    }
}

/* Page turn transitions */
.content-section.page-turn-out {
    transform: perspective(1200px) rotateY(-2deg);
}

.content-section.page-turn-in {
    transform: perspective(1200px) rotateY(2deg);
}

.content-section.page-turn-settle {
    transform: perspective(1200px) rotateY(0deg);
}

/* --- Research Spread Sections --- */
.research-spread {
    grid-template-columns: 1fr;
    padding: 4rem 1.5rem;
}

.research-spread .section-skeleton,
.research-spread .section-content {
    grid-column: 1 / -1;
}

.spread-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 100%;
}

@media (max-width: 768px) {
    .spread-grid {
        grid-template-columns: 1fr;
    }
}

.spread-panel {
    padding: 2rem;
    background: var(--warm-vellum);
    border-radius: 2px;
    box-shadow: inset 0 0 40px rgba(139, 109, 71, 0.08);
    position: relative;
    overflow: hidden;
}

/* Page curl effect on hover */
.spread-panel::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    background: linear-gradient(135deg, transparent 65%, #EDE3D0 65%, #E0D4BC 100%);
    transition: width 0.3s ease, height 0.3s ease;
}

.spread-panel:hover::after {
    width: 40px;
    height: 40px;
}

/* --- Skeleton Loading --- */
.section-skeleton {
    position: relative;
    padding: 1rem 0;
}

.skeleton-lines {
    width: 100%;
    max-width: 500px;
    height: auto;
}

.skel-line {
    fill: var(--skeleton-color);
    opacity: 0.5;
    animation: sketchPulse 2s ease-in-out infinite;
}

.skel-line:nth-child(2) { animation-delay: 0.2s; }
.skel-line:nth-child(3) { animation-delay: 0.4s; }
.skel-line:nth-child(4) { animation-delay: 0.6s; }
.skel-line:nth-child(5) { animation-delay: 0.8s; }

.skel-circle {
    fill: none;
    stroke: var(--skeleton-color);
    stroke-width: 2;
    stroke-dasharray: 3 2;
    opacity: 0.5;
    transform-origin: center;
    transform: rotate(-2deg);
    animation: sketchPulse 2s ease-in-out infinite;
}

.skel-rect {
    fill: var(--skeleton-color);
    opacity: 0.4;
    animation: sketchPulse 2s ease-in-out infinite;
}

@keyframes sketchPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* Skeleton peel transition */
.section-skeleton {
    transition: clip-path 0.4s ease;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.section-skeleton.peeling {
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
}

.section-skeleton.hidden {
    display: none;
}

.section-content {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.section-content.revealed {
    opacity: 1;
}

/* --- Gem Bullet List --- */
.gem-list {
    list-style: none;
    padding-left: 1.5rem;
    margin: 1rem 0 1.5rem;
}

.gem-list li {
    position: relative;
    padding-left: 1.2rem;
    margin-bottom: 0.6rem;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
}

.gem-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.45em;
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpolygon points='6,0 11,3 11,9 6,12 1,9 1,3' fill='none' stroke='%23B8923F' stroke-width='0.8'/%3E%3Cline x1='6' y1='0' x2='6' y2='12' stroke='%23B8923F' stroke-width='0.4' opacity='0.5'/%3E%3Cline x1='1' y1='3' x2='11' y2='9' stroke='%23B8923F' stroke-width='0.4' opacity='0.5'/%3E%3Cline x1='11' y1='3' x2='1' y2='9' stroke='%23B8923F' stroke-width='0.4' opacity='0.5'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    animation: gemGlint 3s ease-in-out infinite;
}

.gem-list li:nth-child(2)::before { animation-delay: 0.5s; }
.gem-list li:nth-child(3)::before { animation-delay: 1s; }
.gem-list li:nth-child(4)::before { animation-delay: 1.5s; }

@keyframes gemGlint {
    0%, 100% { opacity: 0.7; filter: brightness(1); }
    50% { opacity: 1; filter: brightness(1.3); }
}

/* --- Book Divider --- */
.book-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem 0;
}

/* --- Flourish --- */
.section-flourish {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.flourish-path {
    stroke-dasharray: 80;
    stroke-dashoffset: 80;
    transition: stroke-dashoffset 0.6s ease;
}

.flourish-visible .flourish-path {
    stroke-dashoffset: 0;
}

/* --- Data Charts --- */
.chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.data-chart {
    width: 100%;
    max-width: 300px;
    height: auto;
}

.chart-axis {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.4s ease;
}

.chart-axis.drawn {
    stroke-dashoffset: 0;
}

.chart-grid {
    opacity: 0;
    transition: opacity 0.2s ease 0.8s;
}

.chart-grid.visible {
    opacity: 0.08;
}

.data-point {
    fill: var(--dusty-rose);
    stroke: var(--margin-red);
    stroke-width: 1;
    filter: drop-shadow(0 0 3px rgba(184, 146, 63, 0.3));
    transform: scale(0);
    transform-origin: center;
    transform-box: fill-box;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.data-point.visible {
    transform: scale(1);
}

.data-point:hover {
    filter: drop-shadow(0 0 6px rgba(184, 146, 63, 0.6));
    cursor: pointer;
}

.data-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.2s ease;
}

.data-line.drawn {
    stroke-dashoffset: 0;
}

.chart-label {
    font-family: 'Kalam', cursive;
    font-size: 10px;
    fill: var(--ink-brown);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chart-label.visible {
    opacity: 1;
}

.donut-segment {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.donut-segment.visible {
    opacity: 1;
}

.donut-label {
    font-size: 9px;
}

/* --- Sparkle burst container --- */
.sparkle-burst {
    position: absolute;
    pointer-events: none;
    z-index: 100;
}

.sparkle-star {
    position: absolute;
    width: 6px;
    height: 6px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 0 L7 4.5 L12 6 L7 7.5 L6 12 L5 7.5 L0 6 L5 4.5 Z' fill='%23B8923F'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    mix-blend-mode: screen;
}

/* --- Footer --- */
.site-footer {
    background: var(--espresso);
    color: var(--champagne-glint);
    padding: 3rem 1.5rem;
    text-align: center;
    margin-top: 2rem;
}

.footer-text {
    font-family: 'Caveat', cursive;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--champagne-glint);
    margin-bottom: 0.5rem;
}

.footer-domain {
    color: var(--burnished-gold);
}

.footer-sub {
    font-family: 'Kalam', cursive;
    font-size: 0.9rem;
    color: var(--subtle-border);
}

/* --- Interactive Links --- */
a {
    color: var(--burnished-gold);
    text-decoration: none;
    border-bottom: 1px solid var(--burnished-gold);
    transition: color 0.2s ease, border-color 0.2s ease;
}

a:hover {
    color: var(--margin-red);
    border-color: var(--margin-red);
}

/* --- Selection --- */
::selection {
    background: var(--champagne-glint);
    color: var(--dark-walnut);
}

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

::-webkit-scrollbar-track {
    background: var(--aged-parchment);
}

::-webkit-scrollbar-thumb {
    background: var(--subtle-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--margin-red);
}
