/* 
   Young AI Explorers - Print-Ready Design System (V3)
   Optimized for High-Fidelity Professional Printing
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;800&family=Inter:wght@400;500;700&display=swap');

:root {
    --primary: #0EA5E9;
    --secondary: #8B5CF6;
    --accent: #F472B6;
    --dark: #0F172A;
    --light: #F8FAFC;
    --text: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    
    /* Print dimensions - Standard A4 */
    --page-width: 210mm;
    --page-height: 297mm;
    --margin: 10mm; /* Adjusted from 12mm to gain vertical space while remaining KDP safe (min is 6.4mm) */
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background-color: #fff;
    line-height: 1.3; /* Optimized line-height */
    -webkit-print-color-adjust: exact;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
    color: var(--dark);
    font-weight: 800;
}

/* Page Layout */
.page {
    width: var(--page-width);
    min-height: var(--page-height);
    padding: var(--margin);
    margin: 0 auto 20px auto;
    position: relative;
    background: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }
    .page {
        margin: 0;
        box-shadow: none;
        page-break-after: always;
        page-break-inside: avoid;
    }
    
    body {
        background-color: white;
    }
}

/* ANTIGRAVITY COVER DESIGN */
.antigravity-cover {
    background: #020617;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.bg-effects {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0;
    overflow: hidden;
}

.tech-grid {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    z-index: 1;
}

.front-quote {
    position: absolute;
    top: 10pt;
    width: 100%;
    text-align: center;
    color: #F8FAFC;
    font-size: 11pt;
    font-style: italic;
    letter-spacing: 2px;
    text-transform: uppercase;
    z-index: 3;
    opacity: 0.8;
}

.front-quote span {
    color: #FCD34D; /* Gold stars */
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
}

.orb-1 {
    top: -100px;
    left: -100px;
    width: 400px;
    height: 400px;
    background: var(--primary);
}

.orb-2 {
    bottom: -100px;
    right: -100px;
    width: 500px;
    height: 500px;
    background: var(--secondary);
}

.cover-image-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
}

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

.image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(2,6,23,0.1) 0%, rgba(2,6,23,0.95) 100%);
}

.ag-cover-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    width: 100%;
    padding: 40pt;
    text-align: center;
}

.badge-container {
    margin-bottom: auto;
    display: flex;
    gap: 10px;
}

.ag-badge {
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 10pt;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.ag-badge.pro {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

.ag-cover-title {
    display: flex;
    flex-direction: column;
    margin-bottom: 20pt;
}

.ag-title-top, .ag-title-bot {
    font-family: 'Outfit', sans-serif;
    font-size: 32pt;
    font-weight: 800;
    color: white;
    letter-spacing: 8px;
    line-height: 1.2;
    text-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.ag-title-mid {
    font-family: 'Outfit', sans-serif;
    font-size: 100pt;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(135deg, #38BDF8 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ag-cover-subtitle {
    font-size: 18pt;
    color: #94A3B8;
    font-weight: 500;
    letter-spacing: 2px;
    margin-bottom: 40pt;
}

.ag-author-card {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 20pt 40pt;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    width: 80%;
}

.ag-author-card p {
    color: #94A3B8;
    font-size: 10pt;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5pt;
}

.ag-author-card h3 {
    color: white;
    font-size: 24pt;
    margin-bottom: 5pt;
}

.author-tag {
    color: var(--primary);
    font-size: 12pt;
    font-weight: 600;
}

/* Back Cover */
.back-cover {
    background: #0F172A;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.qr-section {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30pt;
}

.qr-placeholder {
    width: 150px;
    height: 150px;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-weight: bold;
}

.legal-text {
    font-size: 12pt;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Table of Contents */
.toc-list {
    list-style: none;
    columns: 2;
    gap: 40px;
}

.toc-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8pt;
    font-size: 11pt;
    border-bottom: 1px dotted var(--border);
}

/* Chapter Layout */
.chapter-header {
    margin-bottom: 8pt; /* Adjusted to prevent footer overlap */
    border-bottom: 4px solid var(--primary);
    padding-bottom: 4pt;
}

.chapter-number {
    font-size: 12pt; /* Slightly smaller for layout fit */
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: block;
}

.chapter-title {
    font-size: 24pt; /* Optimized heading size */
    line-height: 1.1;
}

.section-card {
    background: #F8FAFC;
    border-radius: 16px;
    padding: 8pt 14pt; /* Tighter padding */
    margin-bottom: 6pt; /* Reduced margin */
    border-left: 8px solid var(--primary);
}

.section-card.story { border-color: var(--primary); }
.section-card.lesson { border-color: var(--secondary); }
.section-card.fact { border-color: var(--accent); }
.section-card.quiz { border-color: #10B981; }

.section-label {
    font-size: 9.5pt;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 3pt;
    display: block;
}

.story-text {
    font-style: italic;
    font-size: 11.5pt;
}

.quiz-option {
    display: block;
    padding: 5pt 10pt; /* More compact options */
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 3pt;
    font-size: 10.5pt;
}

.mascot-illustration {
    width: 100%;
    height: 420px; /* Adjusted from 440px to prevent bottom footer overflow */
    margin-bottom: 10pt;
    border-radius: 16px;
    overflow: hidden;
    border: 4px solid var(--primary);
    background-color: #fff;
    box-shadow: 0 10px 25px rgba(14, 165, 233, 0.12); /* Adds a soft premium glow/depth shadow */
}

.mascot-illustration img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 70%; /* Globally shifts the view to reveal the characters at the bottom/center, cropping top ceilings */
    display: block;
}

.mascot-illustration.icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--light) 0%, #E2E8F0 100%);
    font-size: 80pt;
}

/* Icons/Mascots (Keeping as fallback) */
.mascot-thumb {
    float: right;
    width: 120px;
    height: 120px;
    background: var(--light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40pt;
    margin-left: 20pt;
    border: 4px solid var(--primary);
}

/* Footer Info */
.page-footer {
    position: absolute;
    bottom: 8mm; /* Slightly adjusted bottom margin */
    left: var(--margin);
    right: var(--margin);
    display: flex;
    justify-content: space-between;
    font-size: 9pt;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 10pt;
}

/* ANTIGRAVITY BACK COVER */
.ag-back-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 40pt;
    text-align: left;
}

.ag-back-title {
    font-family: 'Outfit', sans-serif;
    font-size: 32pt;
    font-weight: 800;
    color: white;
    line-height: 1.1;
    margin-bottom: 20pt;
    margin-top: 20pt;
    background: linear-gradient(135deg, #F472B6 0%, #8B5CF6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ag-back-blurb {
    font-size: 14pt;
    color: #E2E8F0;
    line-height: 1.6;
    margin-bottom: 30pt;
    font-weight: 400;
}

.ag-features {
    display: flex;
    flex-direction: column;
    gap: 15pt;
    margin-bottom: auto;
}

.ag-feature-item {
    background: rgba(255,255,255,0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 15pt 20pt;
    border-radius: 16px;
    color: white;
    font-size: 14pt;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 15pt;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.ag-feature-item span {
    font-size: 24pt;
}

.ag-author-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 20pt;
    border-radius: 20px;
    margin-top: 20pt;
}

.ag-author-info {
    display: flex;
    align-items: center;
    gap: 15pt;
}

.ag-author-pic {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    object-fit: cover;
}

.ag-author-info h4 {
    color: white;
    font-size: 18pt;
    margin-bottom: 2pt;
    font-family: 'Outfit';
}

.ag-author-info span {
    color: var(--primary);
    font-size: 10pt;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
}

.ag-qr-compact {
    display: flex;
    align-items: center;
    gap: 15pt;
}

.ag-qr-compact img {
    width: 80px;
    border-radius: 8px;
}

.ag-qr-compact span {
    color: #94A3B8;
    font-size: 10pt;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1.4;
    text-align: right;
}

.ag-barcode {
    background: white;
    padding: 10pt;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ag-barcode img {
    height: 60px;
    width: auto;
    margin-bottom: 5px;
}

.ag-barcode span {
    color: black;
    font-size: 8pt;
    letter-spacing: 3px;
    font-family: monospace;
    font-weight: bold;
}

/* Copyright Page Styles */
.copyright-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40mm 20mm;
    color: var(--dark);
}

.copyright-container {
    max-width: 100%;
    margin: auto;
}

.copyright-title {
    font-size: 28pt;
    color: var(--dark);
    margin-bottom: 5pt;
    font-weight: 800;
}

.copyright-subtitle {
    font-size: 16pt;
    color: var(--primary);
    margin-bottom: 40pt;
    font-weight: 600;
    letter-spacing: 1px;
}

.copyright-details {
    font-size: 11pt;
    line-height: 1.6;
    color: var(--text-muted);
}

/* About the Author Page Styles */
.author-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30mm 20mm;
    color: var(--dark);
}

.author-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin: auto;
    max-width: 90%;
}

.author-title {
    font-size: 28pt;
    color: var(--dark);
    margin-bottom: 25pt;
    font-weight: 800;
    border-bottom: 4px solid var(--primary);
    padding-bottom: 8px;
    width: 100%;
}

.author-pic-large {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 6px solid var(--primary);
    object-fit: cover;
    margin-bottom: 20pt;
    box-shadow: 0 10px 25px rgba(14, 165, 233, 0.2);
}

.author-name {
    font-size: 22pt;
    color: var(--dark);
    margin-bottom: 5pt;
    font-weight: 800;
}

.author-subtitle {
    font-size: 12pt;
    color: var(--primary);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 20pt;
}

.author-bio {
    font-size: 12pt;
    line-height: 1.6;
    color: var(--text);
    text-align: center;
    margin-bottom: 25pt;
}

.author-footer-logo {
    font-family: 'Outfit', sans-serif;
    font-size: 14pt;
    font-weight: 800;
    color: var(--dark);
    letter-spacing: 2px;
    opacity: 0.8;
}



/* Sample reader chrome */
body.sample-reader {
  background: #334155;
  padding: 24px 16px 48px;
}
.sample-banner {
  max-width: 210mm;
  margin: 0 auto 16px;
  padding: 12px 16px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  font-family: Inter, sans-serif;
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sample-banner a {
  color: #fcd34d;
  text-decoration: none;
  font-weight: 600;
}
.sample-banner a:hover { text-decoration: underline; }
.cover-page {
  padding: 0 !important;
  min-height: auto !important;
  display: block !important;
}
.cover-page img {
  width: 100%;
  height: auto;
  display: block;
}
.sample-cta {
  max-width: 210mm;
  margin: 24px auto 0;
  padding: 20px;
  background: white;
  border-radius: 12px;
  text-align: center;
  font-family: Inter, sans-serif;
}
.sample-cta h3 { margin-bottom: 8px; color: #0f172a; }
.sample-cta p { color: #64748b; font-size: 14px; margin-bottom: 16px; }
.sample-cta .buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.sample-cta a {
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.sample-cta .amazon { background: #ff9900; color: #000; }
.sample-cta .platform { background: #4a2d6e; color: #faf8f5; }
@media (max-width: 640px) {
  body.sample-reader { padding: 12px 8px 32px; }
  .page { margin-bottom: 12px; }
}
