/*
  Richard P. Feynman - Sta scherzando, Mr. Feynman!
  Cornell Notebook / Sketchbook Design System - Laboratorio STEM
*/

:root {
    --bg-notebook: #fdfaf2; /* Soft creamy notebook paper */
    --ink-black: #2c3e50;
    --cornell-red: #b31b1b; /* Cornell University Crimson */
    --pencil-lead: #7f8c8d;
    --highlight-yellow: #f1c40f;
    --grid-line-blue: rgba(52, 152, 219, 0.08);
    --grid-line-red: rgba(231, 76, 60, 0.15);
    
    --font-main: 'Inter', sans-serif;
    --font-hand: 'Caveat', cursive;
    --font-mono: 'Space Grotesk', sans-serif;
    
    --shadow-notebook: 3px 3px 0px rgba(44, 62, 80, 0.15);
    --border-sketch: 2px solid #2c3e50;
    --border-radius: 6px;
}

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

body {
    background-color: var(--bg-notebook);
    color: var(--ink-black);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Notebook Grid Lines */
.notebook-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: 
        linear-gradient(var(--grid-line-blue) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line-blue) 1px, transparent 1px);
    background-size: 24px 24px;
    pointer-events: none;
    z-index: 0;
}

/* Red Margin Line on the left */
.notebook-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 80px;
    width: 2px;
    height: 100%;
    background: var(--grid-line-red);
}

main, nav, footer, .modal-backdrop {
    position: relative;
    z-index: 1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Navigation */
#main-nav {
    background: rgba(253, 250, 242, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 2px solid var(--ink-black);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.logo {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--ink-black);
}

.logo span {
    color: var(--cornell-red);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--ink-black);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.2s, transform 0.2s;
}

.nav-links a:hover {
    color: var(--cornell-red);
    transform: translateY(-1px);
}

/* Hero Section */
.hero {
    padding: 5rem 0 4rem;
    display: flex;
    align-items: center;
    min-height: calc(100vh - 70px);
}

.hero-content {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 4rem;
    align-items: center;
}

.hero-badge {
    display: inline-block;
    background: rgba(179, 27, 27, 0.08);
    border: 2px solid var(--cornell-red);
    color: var(--cornell-red);
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.hero-title {
    font-family: var(--font-hand);
    font-size: 4.2rem;
    line-height: 1.1;
    color: var(--cornell-red);
    margin-bottom: 0.5rem;
}

.hero-subtitle {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: var(--ink-black);
    margin-bottom: 1.5rem;
}

.author-name {
    font-size: 1.15rem;
    color: var(--pencil-lead);
    margin-bottom: 2rem;
}

.hero-intro {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 2.5rem;
}

.hero-btns {
    display: flex;
    gap: 1.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.8rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: var(--border-radius);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: var(--border-sketch);
}

.btn-primary {
    background: var(--cornell-red);
    color: #fff;
    box-shadow: var(--shadow-notebook);
}

.btn-primary:hover {
    background: var(--bg-notebook);
    color: var(--cornell-red);
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0px rgba(179, 27, 27, 0.2);
}

.btn-secondary {
    background: transparent;
    color: var(--ink-black);
    box-shadow: var(--shadow-notebook);
}

.btn-secondary:hover {
    background: var(--ink-black);
    color: #fff;
    transform: translate(-2px, -2px);
}

/* Book Cover Styling */
.book-cover-container {
    position: relative;
    border-radius: var(--border-radius);
    border: var(--border-sketch);
    box-shadow: 5px 5px 0px rgba(44, 62, 80, 0.2);
    overflow: hidden;
    aspect-ratio: 1 / 1.5;
    background: #000;
    transition: transform 0.4s ease;
}

.book-cover-container:hover {
    transform: rotate(-1deg) scale(1.02);
}

#cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-cover-fallback {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2.5rem;
    background: var(--bg-notebook);
    border: 4px solid var(--cornell-red);
    color: var(--ink-black);
    text-align: center;
}

.fallback-title {
    font-family: var(--font-hand);
    font-size: 2.4rem;
    color: var(--cornell-red);
}

.fallback-author {
    font-family: var(--font-mono);
    font-size: 1.15rem;
}

.fallback-logo {
    font-weight: bold;
    font-size: 0.9rem;
    letter-spacing: 2px;
}

/* General Sections */
section {
    padding: 6rem 0;
}

.section-dark-alt {
    background: rgba(44, 62, 80, 0.02);
    border-top: 2px solid var(--ink-black);
    border-bottom: 2px solid var(--ink-black);
}

.section-title {
    font-family: var(--font-hand);
    font-size: 3.2rem;
    color: var(--cornell-red);
    text-align: center;
    margin-bottom: 1rem;
}

.section-subtitle {
    font-family: var(--font-mono);
    text-align: center;
    max-width: 700px;
    margin: 0 auto 3.5rem;
    color: var(--pencil-lead);
    font-size: 1rem;
}

/* Sketch/Notebook Cards */
.glass-card {
    background: #fff;
    border: var(--border-sketch);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-notebook);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.glass-card:hover {
    transform: translate(-3px, -3px);
    box-shadow: 6px 6px 0px rgba(44, 62, 80, 0.2);
}

/* Biography & Author Section */
.author-summary-box {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 3.5rem;
    border-left: 5px solid var(--cornell-red);
}

.box-icon {
    font-size: 3rem;
}

.box-text h3 {
    font-family: var(--font-mono);
    color: var(--cornell-red);
    margin-bottom: 0.5rem;
}

.biography-grid {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr;
    gap: 4rem;
    align-items: center;
}

.author-photo-wrapper {
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 1;
    border: var(--border-sketch);
    padding: 5px;
    background: #fff;
    box-shadow: var(--shadow-notebook);
}

#author-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-fallback-svg {
    width: 100%;
    height: 100%;
    background: var(--bg-notebook);
}

.biography-content h3 {
    font-family: var(--font-hand);
    font-size: 2.2rem;
    color: var(--cornell-red);
    margin-bottom: 1.5rem;
}

.biography-content p {
    margin-bottom: 1.5rem;
    color: rgba(44, 62, 80, 0.9);
}

/* Why This Book Matters Cards */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 1.2rem;
}

.card h3 {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: var(--cornell-red);
}

.card p {
    color: var(--pencil-lead);
    font-size: 0.95rem;
}

/* Timeline/Journey Section */
.journey-flow {
    position: relative;
    padding: 3rem 0;
    max-width: 1000px;
    margin: 0 auto;
}

.flow-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--ink-black);
    transform: translateY(-50%);
    z-index: 1;
}

.journey-nodes {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 2;
}

.journey-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    width: 120px;
    text-align: center;
}

.node-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-notebook);
    border: var(--border-sketch);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-family: var(--font-mono);
    margin-bottom: 1rem;
    transition: all 0.25s ease;
}

.journey-node:hover .node-dot {
    background: var(--cornell-red);
    color: #fff;
    transform: scale(1.15);
}

.node-title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink-black);
}

/* Cornell Plate Simulator Container */
.sandbox-container {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 3rem;
    margin-top: 2rem;
    align-items: center;
}

.canvas-container {
    border: var(--border-sketch);
    box-shadow: var(--shadow-notebook);
    border-radius: 12px;
}

.sandbox-controls {
    background: #fff;
    border: var(--border-sketch);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow-notebook);
}

.sandbox-controls h3 {
    font-family: var(--font-mono);
    color: var(--cornell-red);
    margin-bottom: 1.5rem;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(44,62,80,0.15);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--cornell-red);
    cursor: pointer;
    border: 2px solid var(--ink-black);
}

.sandbox-buttons {
    display: flex;
    gap: 1rem;
}

.sandbox-buttons .btn {
    flex: 1;
}

/* Concepts Grid */
.concepts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 2rem;
}

.concept-card {
    cursor: pointer;
}

.concept-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.concept-num {
    font-family: var(--font-mono);
    color: var(--cornell-red);
    font-weight: bold;
    font-size: 0.9rem;
}

.concept-title-card {
    font-family: var(--font-mono);
    color: var(--ink-black);
    font-size: 1.25rem;
}

.concept-body {
    font-size: 0.9rem;
    color: var(--pencil-lead);
}

.concept-card:hover .concept-title-card {
    color: var(--cornell-red);
}

/* Portals Section */
.portals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.portal-card {
    cursor: pointer;
    text-align: center;
    border: 2px dashed rgba(44, 62, 80, 0.4);
}

.portal-card:hover {
    border-color: var(--cornell-red);
}

.portal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.portal-title {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--cornell-red);
}

.portal-feedback-card {
    border: var(--border-sketch);
    background: rgba(179, 27, 27, 0.03);
    margin-top: 2rem;
    animation: fadeIn 0.4s ease;
}

.portal-feedback-title {
    font-family: var(--font-hand);
    font-size: 2.2rem;
    color: var(--cornell-red);
    margin-bottom: 1rem;
}

/* Narrative Section */
.narrative-card {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem;
    border: var(--border-sketch);
    border-radius: var(--border-radius);
    background: #fff;
    box-shadow: var(--shadow-notebook);
}

.narrative-card h2 {
    font-family: var(--font-hand);
    font-size: 2.6rem;
    color: var(--cornell-red);
    margin-bottom: 1.5rem;
}

.narrative-main {
    font-size: 1.3rem;
    font-weight: 500;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    color: var(--cornell-red);
    border-left: 3px solid var(--cornell-red);
    padding-left: 1.5rem;
}

/* Takeaways */
.takeaways-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.takeaway-item {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.takeaway-num {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    color: #fff;
    background: var(--cornell-red);
    border: var(--border-sketch);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.takeaway-text h3 {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    color: var(--ink-black);
    margin-bottom: 0.3rem;
}

.takeaway-text p {
    color: var(--pencil-lead);
}

/* Target profiles */
.profiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.profile-card h3 {
    font-family: var(--font-mono);
    font-size: 1.2rem;
    color: var(--cornell-red);
    margin-bottom: 0.8rem;
}

.profile-card p {
    color: var(--pencil-lead);
}

/* Footer */
#main-footer {
    border-top: 2px solid var(--ink-black);
    padding: 3rem 0;
    text-align: center;
    background: #fff;
}

.footer-note {
    font-size: 0.85rem;
    color: var(--pencil-lead);
    margin-top: 1rem;
}

.footer-note a {
    color: var(--cornell-red);
    text-decoration: underline;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(44, 62, 80, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: var(--bg-notebook);
    border: var(--border-sketch);
    box-shadow: 6px 6px 0px rgba(44, 62, 80, 0.3);
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    padding: 2.5rem;
    position: relative;
    animation: zoomIn 0.25s ease;
}

@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: transparent;
    border: none;
    color: var(--ink-black);
    font-size: 2.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--cornell-red);
}

.modal-body h2 {
    font-family: var(--font-hand);
    font-size: 2.5rem;
    color: var(--cornell-red);
    margin-bottom: 1.5rem;
}

.modal-body h4 {
    font-family: var(--font-mono);
    color: var(--ink-black);
    margin-bottom: 1rem;
}

.modal-body p {
    margin-bottom: 1.5rem;
    color: rgba(44, 62, 80, 0.9);
}

.modal-body blockquote {
    border-left: 3px solid var(--cornell-red);
    padding-left: 1rem;
    font-style: italic;
}

/* Responsive */
@media (max-width: 992px) {
    .hero-content {
        grid-template-columns: 1fr;
        gap: 3rem;
        text-align: center;
    }
    
    .hero-btns {
        justify-content: center;
    }
    
    .biography-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .author-photo-wrapper {
        max-width: 300px;
        margin: 0 auto;
    }
    
    .sandbox-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 768px) {
    .journey-nodes {
        flex-direction: column;
        gap: 2rem;
        align-items: flex-start;
        padding-left: 2rem;
    }
    
    .flow-line {
        left: 38px;
        width: 4px;
        height: 100%;
        top: 0;
        transform: none;
    }
    
    .journey-node {
        flex-direction: row;
        width: 100%;
        text-align: left;
        gap: 1.5rem;
    }
    
    .node-dot {
        margin-bottom: 0;
    }
}
