/* Professional stylesheet for I Ching Astronomical Design research paper */
/* Parchment aesthetic with subtle texture and warm tones */

:root {
    /* Parchment palette */
    --parchment: #f5f0e6;
    --parchment-light: #faf6ed;
    --parchment-dark: #e8dcc8;
    --parchment-edge: #d8c9a8;

    /* Ink colors */
    --ink: #3d3630;
    --ink-dark: #2a2420;
    --ink-light: #5c534a;
    --ink-muted: #8a7f72;

    /* Sepia accents */
    --sepia: #8b7355;
    --sepia-light: #c4a77d;
    --sepia-dark: #6b5545;

    /* Borders and dividers */
    --border-warm: #d4c4a8;
    --border-light: #e5dbc5;

    /* Legacy compatibility aliases */
    --charcoal: var(--ink);
    --charcoal-dark: var(--ink-dark);
    --silver: var(--border-warm);
    --platinum: var(--parchment-light);
    --warm-gray: var(--parchment);
    --text-dark: var(--ink);
    --text-light: var(--ink-muted);
    --bg-light: var(--parchment-light);
    --border: var(--border-warm);
}

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

html {
    font-size: 16px;
    line-height: 1.6;
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    font-family: 'century-gothic', 'Georgia', sans-serif;
    color: var(--text-dark);
    background: var(--parchment);
    margin: 0;
    padding: 0;
    position: relative;
    overflow-x: clip;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Subtle paper texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* Ensure content is above texture */
body > * {
    position: relative;
    z-index: 1;
}

.content-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Full-page cover page */
.cover-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 3rem 2rem;
    background:
        radial-gradient(ellipse at center, transparent 0%, rgba(139, 115, 85, 0.08) 100%),
        linear-gradient(135deg, var(--parchment-dark) 0%, var(--parchment-light) 50%, var(--parchment-dark) 100%);
    border-bottom: 2px solid var(--border-warm);
}

.cover-title-english {
    font-family: 'eds-market', 'Helvetica Neue', sans-serif;
    font-size: 2.8rem;
    font-weight: 300;
    color: var(--charcoal-dark);
    line-height: 1.3;
    margin: 0 0 2rem;
    max-width: 800px;
    letter-spacing: -0.02em;
}

.cover-title-chinese {
    font-family: 'Noto Serif SC', 'STSong', 'SimSun', serif;
    font-size: 2rem;
    font-weight: 400;
    color: var(--charcoal);
    margin: 0 0 4rem;
    letter-spacing: 0.05em;
}

.cover-metadata {
    margin-top: 3rem;
    font-family: 'century-gothic', 'Helvetica Neue', sans-serif;
    font-size: 0.95rem;
    color: var(--text-light);
    line-height: 1.8;
}

.cover-metadata strong {
    color: var(--charcoal);
    font-weight: 600;
}

.cover-metadata p {
    margin: 0.3rem 0;
    text-align: center;
}

.scroll-indicator {
    margin-top: 4rem;
    font-size: 0.85rem;
    color: var(--text-light);
    opacity: 0.6;
    animation: fadeInOut 2s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Headers */
h1 {
    font-family: 'eds-market', 'Helvetica Neue', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--ink-dark);
    margin: 2rem 0 1rem;
    line-height: 1.2;
    border-bottom: 2px solid var(--sepia-light);
    padding-bottom: 0.5rem;
}

h2 {
    font-family: 'eds-market', 'Helvetica Neue', sans-serif;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--ink);
    margin: 2.5rem 0 1rem;
    border-bottom: 1px solid var(--border-warm);
    padding-bottom: 0.3rem;
}

h3 {
    font-family: 'eds-market', 'Helvetica Neue', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--charcoal);
    margin: 2rem 0 0.8rem;
}

h4 {
    font-family: 'eds-market', 'Helvetica Neue', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 1.5rem 0 0.6rem;
}

/* Paragraphs */
p {
    margin: 1rem 0;
    text-align: justify;
}

/* Links */
a {
    color: var(--sepia-dark);
    text-decoration: none;
    transition: color 0.2s;
    border-bottom: 1px solid transparent;
}

a:hover {
    color: var(--sepia);
    border-bottom: 1px solid var(--sepia-light);
}

/* Table of Contents */
#TOC {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    font-size: 0.95rem;
}

#TOC ul {
    list-style: none;
    padding-left: 0;
}

#TOC > ul > li {
    margin: 0.5rem 0;
}

#TOC ul ul {
    padding-left: 1.5rem;
    margin-top: 0.3rem;
}

#TOC li {
    margin: 0.3rem 0;
}

#TOC a {
    color: var(--text-dark);
}

#TOC a:hover {
    color: var(--charcoal);
}

/* Figures and Images */
figure {
    margin: 2rem 0;
    text-align: center;
}

img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Figure 3 - Calendar Drift - enlarged and stretched vertically */
img[src*="figure_3_calendar_drift"] {
    max-width: 105%;
    transform: scaleY(1.15);
    margin: 1.5rem 0;
}

figcaption, .caption {
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-light);
    margin-top: 0.5rem;
    text-align: left;
    padding: 0 1rem;
}

/* Tables - Elegant Contemporary Design */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2rem auto;
    font-size: 0.9rem;
    background: white;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

caption {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--charcoal);
    text-align: left;
    padding: 0.5rem 0 1rem;
    letter-spacing: 0.01em;
}

thead {
    background: linear-gradient(180deg, var(--charcoal) 0%, #323232 100%);
}

th {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 1rem 1.25rem;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #404040;
}

tbody tr {
    transition: background-color 0.15s ease;
}

td {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid #e8e8e8;
    color: var(--text-dark);
    line-height: 1.5;
}

/* Right-align numeric columns */
td:nth-child(n+2) {
    text-align: left;
}

td[align="right"],
td:has(> strong:only-child),
td:matches(:contains('0.'), :contains('×'), :contains('p'), :contains('%')) {
    font-variant-numeric: tabular-nums;
}

/* Zebra striping with warm gray */
tbody tr:nth-child(even) {
    background: var(--warm-gray);
}

tbody tr:nth-child(odd) {
    background: #ffffff;
}

/* Refined hover effect */
tbody tr:hover {
    background: var(--platinum);
    box-shadow: inset 0 0 0 1px #e0e0e0;
}

/* Last row - no border */
tbody tr:last-child td {
    border-bottom: none;
}

/* Emphasis in tables */
table strong {
    color: var(--charcoal-dark);
    font-weight: 600;
}

table em {
    font-style: italic;
    color: var(--text-light);
}

/* Significance levels with graduated styling */
.sig-high {
    color: #1a1a1a;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.1em;
    text-align: center;
}

.sig-med {
    color: #404040;
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.12em;
    text-align: center;
}

.sig-low {
    color: #666666;
    font-weight: 500;
    font-size: 1rem;
    text-align: center;
}

.sig-none {
    color: #999999;
    font-weight: 400;
    opacity: 0.6;
    font-size: 1rem;
    text-align: center;
}

/* Code blocks */
pre {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-left: 4px solid var(--charcoal);
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 1rem 0;
}

code {
    background: var(--bg-light);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

pre code {
    background: none;
    padding: 0;
}

/* Blockquotes */
blockquote {
    border-left: 4px solid var(--silver);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--text-light);
}

/* Lists */
ul, ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

li {
    margin: 0.5rem 0;
}

/* Horizontal rules */
hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 3rem 0;
}

/* Emphasis */
em {
    font-style: italic;
    color: var(--text-dark);
}

strong {
    font-weight: 700;
    color: var(--charcoal-dark);
}

/* Superscript and subscript */
sup, sub {
    font-size: 0.75em;
    line-height: 0;
}

/* Header metadata */
.author, .affiliation, .contact, .date, .version {
    font-family: 'century-gothic', 'Helvetica Neue', sans-serif;
    color: var(--text-light);
    margin: 0.3rem 0;
}

/* Abstract */
.abstract {
    background: linear-gradient(135deg, var(--parchment-light) 0%, var(--parchment) 100%);
    border-left: 4px solid var(--sepia);
    padding: 1.5rem;
    margin: 2rem 0;
    font-size: 0.95rem;
    box-shadow: inset 0 0 20px rgba(139, 115, 85, 0.05);
}

/* Responsive design */
@media screen and (max-width: 768px) {
    /* Lock content to viewport on mobile - prevent iOS rubber-banding */
    html, body {
        position: relative;
        width: 100%;
        overflow-x: clip;
        overscroll-behavior-x: none;
    }

    .content-wrapper {
        padding: 1rem;
        width: 100%;
        max-width: 100vw;
        overflow-x: clip;
    }

    .cover-page {
        padding: 2rem 1rem;
        width: 100%;
        max-width: 100vw;
    }

    .cover-title-english {
        font-size: 1.8rem;
    }

    .cover-title-chinese {
        font-size: 1.4rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.2rem;
    }

    table {
        font-size: 0.8rem;
    }

    th, td {
        padding: 0.5rem;
    }
}

/* Print styles */
@media print {
    body {
        max-width: 100%;
        font-size: 12pt;
        line-height: 1.5;
    }

    h1, h2, h3 {
        page-break-after: avoid;
    }

    img, figure, table {
        page-break-inside: avoid;
    }

    a {
        color: black;
        text-decoration: none;
    }

    pre {
        border: 1px solid black;
        page-break-inside: avoid;
    }
}

/* PDF Download Button */
.pdf-download {
    display: inline-block;
    margin: 1.5rem 0;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(180deg, var(--charcoal) 0%, var(--charcoal-dark) 100%);
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-family: 'century-gothic', 'Helvetica Neue', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pdf-download:hover {
    background: linear-gradient(180deg, var(--charcoal-dark) 0%, #000000 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-1px);
    color: #ffffff;
    text-decoration: none;
}

/* Header anchor links */
h2, h3, h4 {
    position: relative;
}

.header-anchor {
    margin-left: 0.5rem;
    color: var(--text-light);
    text-decoration: none;
    font-weight: 400;
    opacity: 0.6;
    transition: opacity 0.2s ease, color 0.2s ease;
}

h2:hover .header-anchor,
h3:hover .header-anchor,
h4:hover .header-anchor {
    opacity: 1;
}

.header-anchor:hover {
    color: var(--charcoal-dark);
    opacity: 1;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    :root {
        --charcoal: #000000;
        --charcoal-dark: #000000;
        --silver: #000000;
        --text-dark: #000000;
        --border: #000000;
    }
}

/* ========================================
   Decorative Elements - Parchment Theme
   ======================================== */

/* Ornamental section divider */
.section-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 3rem 0;
    gap: 1rem;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    max-width: 120px;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--sepia-light) 50%, transparent 100%);
}

.section-divider::before {
    background: linear-gradient(90deg, transparent 0%, var(--sepia-light) 100%);
}

.section-divider::after {
    background: linear-gradient(90deg, var(--sepia-light) 0%, transparent 100%);
}

.section-divider-symbol {
    color: var(--sepia);
    font-size: 1.2rem;
    opacity: 0.7;
}

/* Drop cap for first paragraph of major sections */
.drop-cap::first-letter {
    float: left;
    font-family: 'eds-market', 'Georgia', serif;
    font-size: 3.5rem;
    line-height: 0.8;
    padding-right: 0.15em;
    padding-top: 0.1em;
    color: var(--sepia);
}

/* Print styles - remove texture for cleaner printing */
@media print {
    body::before {
        display: none;
    }

    body {
        background: #fff;
    }

    .cover-page {
        background: #fff;
    }

    a {
        color: var(--ink);
        border-bottom: none;
    }
}
