/* ==========================================================================
   The Digital Gazette — Newspaper Editorial Theme
   ========================================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;0,800;0,900;1,400;1,700&family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&display=swap');

/* --- CSS Variables --- */
:root {
    --color-ink:        #1a1a1a;
    --color-ink-light:  #3d3d3d;
    --color-ink-muted:  #6b6b6b;
    --color-paper:      #f8f5f0;
    --color-paper-dark: #ede8e0;
    --color-accent:     #8b0000;
    --color-accent-light: #a52a2a;
    --color-gold:       #b8860b;
    --color-rule:       #2c2c2c;
    --color-rule-light: #c4b9a8;

    --font-display:     'Playfair Display', 'Georgia', serif;
    --font-body:        'Sarabun', 'Helvetica Neue', sans-serif;
    --font-accent:      'Cormorant Garamond', 'Georgia', serif;

    --max-width:        820px;
    --spacing-unit:     1rem;
}

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

html {
    font-size: 18px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    line-height: 1.85;
    color: var(--color-ink);
    background-color: var(--color-paper);
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1.85rem,
            rgba(0,0,0,0.012) 1.85rem,
            rgba(0,0,0,0.012) calc(1.85rem + 1px)
        );
}

/* --- Utility --- */
::selection {
    background-color: var(--color-accent);
    color: #fff;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.site-header {
    text-align: center;
    padding: 0 var(--spacing-unit);
}

.header-top-line {
    height: 6px;
    background: var(--color-rule);
    margin-bottom: 0;
}

.header-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 0 1.2rem;
}

.header-date {
    font-family: var(--font-accent);
    font-size: 0.78rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-ink-muted);
    margin-bottom: 0.8rem;
}

.site-title {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2.4rem, 6vw, 3.8rem);
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: var(--color-ink);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.site-slogan {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: var(--color-ink-muted);
    margin-bottom: 0.8rem;
}

.header-edition {
    display: inline-block;
    font-family: var(--font-accent);
    font-size: 0.72rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    padding: 0.25em 1.2em;
    font-weight: 600;
}

.header-bottom-border {
    max-width: var(--max-width);
    margin: 0 auto;
    border-bottom: 3px double var(--color-rule);
    position: relative;
}

.header-bottom-border::after {
    content: '';
    display: block;
    border-bottom: 1px solid var(--color-rule);
    margin-top: 4px;
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */

.newspaper-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem var(--spacing-unit) 3rem;
}

/* --- Article Meta --- */
.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--color-rule-light);
}

.article-category {
    font-family: var(--font-accent);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #fff;
    background: var(--color-accent);
    padding: 0.2em 0.8em;
}

.article-reading-time {
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--color-ink-muted);
    font-weight: 300;
}

/* --- Headline --- */
.headline {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.8rem, 4.5vw, 2.6rem);
    line-height: 1.25;
    color: var(--color-ink);
    margin-bottom: 1.5rem;
    letter-spacing: -0.01em;
}

/* --- Article Hero Image --- */
.article-hero {
    margin: 0 0 2rem 0;
}

.article-hero img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--color-rule-light);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.article-hero figcaption {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 300;
    font-style: italic;
    color: var(--color-ink-muted);
    text-align: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--color-rule-light);
}

/* --- Section Images --- */
.section-image {
    margin: 1rem 0 1.2rem 0;
}

.section-image img {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--color-rule-light);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s ease;
}

.section-image img:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
}

/* --- Lead Paragraph --- */
.lead-paragraph {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 400;
    line-height: 2;
    color: var(--color-ink-light);
    border-left: 3px solid var(--color-accent);
    padding-left: 1.2rem;
    margin-bottom: 2rem;
}

/* --- Article Divider --- */
.article-divider {
    text-align: center;
    margin: 2.5rem 0;
    position: relative;
}

.article-divider::before {
    content: '✦  ✦  ✦';
    font-size: 0.6rem;
    letter-spacing: 0.5em;
    color: var(--color-rule-light);
    background: var(--color-paper);
    padding: 0 1rem;
    position: relative;
    z-index: 1;
}

.article-divider::after {
    content: '';
    display: block;
    border-top: 1px solid var(--color-rule-light);
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
}

/* --- Sections --- */
.article-section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 1.55rem);
    line-height: 1.35;
    color: var(--color-ink);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-rule-light);
    position: relative;
}

.section-number {
    font-family: var(--font-accent);
    font-weight: 700;
    font-size: 0.85em;
    color: var(--color-accent);
    margin-right: 0.4em;
}

.article-section p {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.95;
    color: var(--color-ink-light);
    margin-bottom: 1rem;
    text-align: justify;
    text-justify: inter-character;
    hyphens: auto;
}

.article-section p:last-child {
    margin-bottom: 0;
}

.article-section p strong {
    font-weight: 600;
    color: var(--color-ink);
}

/* --- Conclusion --- */
.article-conclusion {
    background: var(--color-paper-dark);
    padding: 1.8rem 2rem;
    border: 1px solid var(--color-rule-light);
    position: relative;
}

.article-conclusion::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-accent);
}

.article-conclusion .section-title {
    border-bottom-color: var(--color-rule-light);
}

.article-conclusion p {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.95;
    color: var(--color-ink-light);
    text-align: justify;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

.site-footer {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--spacing-unit) 3rem;
}

.footer-border {
    border-top: 3px double var(--color-rule);
    position: relative;
    margin-bottom: 1.5rem;
}

.footer-border::after {
    content: '';
    display: block;
    border-top: 1px solid var(--color-rule);
    margin-top: 4px;
}

.footer-container {
    text-align: center;
}

.footer-nav {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-rule-light);
}

.footer-nav a {
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-nav a:hover {
    color: var(--color-ink);
    text-decoration: underline;
}

.footer-nav-sep {
    color: var(--color-rule-light);
    margin: 0 0.5rem;
    font-size: 0.8rem;
}

.footer-copyright {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-ink);
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.footer-signature {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--color-ink-muted);
    letter-spacing: 0.03em;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto 1rem;
}

.footer-ornament {
    font-size: 0.75rem;
    color: var(--color-rule-light);
    letter-spacing: 0.3em;
}

/* ==========================================================================
   LEGAL SECTIONS (Privacy Policy, Terms)
   ========================================================================== */

.legal-section {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2.5rem var(--spacing-unit) 2rem;
    border-top: 2px solid var(--color-rule-light);
}

.legal-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--color-ink);
    margin-bottom: 0.3rem;
}

.legal-updated {
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--color-ink-muted);
    font-style: italic;
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--color-rule-light);
}

.legal-content h3 {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--color-ink);
    margin-top: 1.2rem;
    margin-bottom: 0.4rem;
}

.legal-content p {
    font-family: var(--font-body);
    font-size: 0.82rem;
    line-height: 1.8;
    color: var(--color-ink-muted);
    margin-bottom: 0.6rem;
}

.legal-content a {
    color: var(--color-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.legal-content a:hover {
    border-bottom-color: var(--color-accent);
}

/* ==========================================================================
   CONTACT SECTION
   ========================================================================== */

.contact-content {
    margin-top: 1.2rem;
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.contact-card {
    background: var(--color-paper-dark);
    border: 1px solid var(--color-rule-light);
    padding: 1.2rem;
    text-align: center;
    transition: box-shadow 0.3s ease;
}

.contact-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.contact-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

.contact-card h3 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--color-ink);
    margin-bottom: 0.4rem;
}

.contact-card p {
    font-family: var(--font-body);
    font-size: 0.78rem;
    color: var(--color-ink-muted);
    line-height: 1.6;
    margin: 0;
}

.contact-card a {
    color: var(--color-accent);
    text-decoration: none;
}

.contact-card a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   COOKIE CONSENT BANNER
   ========================================================================== */

.cookie-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--color-ink);
    color: #fff;
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.cookie-consent.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.cookie-content {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
}

.cookie-content p {
    font-family: var(--font-body);
    font-size: 0.78rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
    flex: 1;
    min-width: 200px;
}

.cookie-content p a {
    color: #e8d9a0;
    text-decoration: underline;
}

.cookie-buttons {
    display: flex;
    gap: 0.6rem;
    flex-shrink: 0;
}

.cookie-btn {
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.5em 1.3em;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.cookie-btn:active {
    transform: scale(0.97);
}

.cookie-accept {
    background: var(--color-accent);
    color: #fff;
}

.cookie-accept:hover {
    background: var(--color-accent-light);
}

.cookie-decline {
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.cookie-decline:hover {
    color: #fff;
    border-color: #fff;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 600px) {
    html {
        font-size: 16px;
    }

    .header-container {
        padding: 1.5rem 0 1rem;
    }

    .site-title {
        font-size: 2rem;
    }

    .lead-paragraph {
        font-size: 1rem;
        padding-left: 1rem;
    }

    .article-conclusion {
        padding: 1.2rem 1rem;
    }

    .article-section p {
        text-align: left;
    }

    .article-conclusion p {
        text-align: left;
    }

    .image-click-hint {
        opacity: 1;
        font-size: 0.62rem;
    }

    .image-ref-overlay {
        padding: 1rem 1.2rem;
    }

    .ref-badge {
        font-size: 0.82rem;
    }

    .ref-list li {
        font-size: 0.72rem;
    }

    .references-section {
        padding: 1.2rem 1rem;
    }

    .references-list {
        padding-left: 1.4rem;
    }
}

@media (min-width: 1200px) {
    .newspaper-content {
        columns: 2;
        column-gap: 2.5rem;
        column-rule: 1px solid var(--color-rule-light);
    }

    .article-meta,
    .headline,
    .article-hero,
    .lead-paragraph,
    .article-divider {
        column-span: all;
    }

    .article-section {
        break-inside: avoid;
    }

    .article-conclusion {
        column-span: all;
    }

    .references-section {
        column-span: all;
    }
}

/* --- Print Styles --- */
@media print {
    body {
        background: #fff;
        background-image: none;
    }

    .site-header,
    .site-footer {
        break-inside: avoid;
    }

    .image-ref-overlay,
    .image-click-hint {
        display: none !important;
    }
}

/* ==========================================================================
   IMAGE REFERENCE OVERLAY (Click to reveal)
   ========================================================================== */

.image-ref-wrapper {
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.image-ref-wrapper img {
    display: block;
    width: 100%;
    height: auto;
    transition: filter 0.35s ease;
}

/* Hint badge (always visible) */
.image-click-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 400;
    padding: 0.3em 0.7em;
    border-radius: 3px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.image-ref-wrapper:hover .image-click-hint {
    opacity: 1;
}

.hint-icon {
    margin-right: 0.2em;
}

/* Overlay (hidden by default, shown on click) */
.image-ref-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(26, 26, 26, 0.75) 0%,
        rgba(26, 26, 26, 0.92) 100%
    );
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1.5rem 2rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    z-index: 3;
}

.image-ref-wrapper.show-ref img {
    filter: brightness(0.4);
}

.image-ref-wrapper.show-ref .image-ref-overlay {
    opacity: 1;
    visibility: visible;
}

.image-ref-wrapper.show-ref .image-click-hint {
    opacity: 0;
}

.ref-badge {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    color: #fff;
    margin-bottom: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    letter-spacing: 0.03em;
}

.ref-icon {
    margin-right: 0.3em;
}

.ref-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: 500px;
}

.ref-list li {
    margin-bottom: 0.5rem;
    font-family: var(--font-body);
    font-size: 0.78rem;
    line-height: 1.5;
    position: relative;
    padding-left: 1rem;
}

.ref-list li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.7rem;
}

.ref-list li a {
    color: #e8d9a0;
    text-decoration: none;
    border-bottom: 1px solid rgba(232, 217, 160, 0.3);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.ref-list li a:hover {
    color: #fff;
    border-bottom-color: #fff;
}

.ref-tap-hint {
    font-family: var(--font-body);
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 1rem;
    font-style: italic;
}

/* ==========================================================================
   FOOTNOTES (Superscript references in text)
   ========================================================================== */

.footnote-ref {
    font-family: var(--font-body);
    font-size: 0.65em;
    vertical-align: super;
    line-height: 0;
}

.footnote-ref a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    padding: 0 0.1em;
    transition: color 0.2s ease;
}

.footnote-ref a:hover {
    color: var(--color-accent-light);
    text-decoration: underline;
}

/* ==========================================================================
   REFERENCES SECTION (Bottom of article)
   ========================================================================== */

.references-section {
    margin-top: 1rem;
    padding: 2rem;
    background: var(--color-paper-dark);
    border: 1px solid var(--color-rule-light);
    position: relative;
}

.references-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--color-gold);
}

.references-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--color-ink);
    margin-bottom: 1.5rem;
    padding-bottom: 0.6rem;
    border-bottom: 2px solid var(--color-rule-light);
}

.references-group {
    margin-bottom: 1.2rem;
}

.references-group:last-child {
    margin-bottom: 0;
}

.ref-group-label {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--color-ink-light);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.4rem;
}

.references-list {
    padding-left: 1.8rem;
    margin: 0;
}

.references-list li {
    font-family: var(--font-body);
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--color-ink-muted);
    margin-bottom: 0.2rem;
    padding-left: 0.3rem;
}

.references-list li::marker {
    font-weight: 600;
    color: var(--color-accent);
}

.references-list li a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.references-list li a:hover {
    border-bottom-color: var(--color-accent);
}

/* Smooth scroll target highlight */
.references-list li:target {
    background: rgba(139, 0, 0, 0.06);
    border-radius: 3px;
    padding: 0.2rem 0.3rem;
    margin-left: -0.3rem;
    animation: refHighlight 2s ease-out;
}

@keyframes refHighlight {
    0% { background: rgba(139, 0, 0, 0.15); }
    100% { background: rgba(139, 0, 0, 0.06); }
}
