/*
 * main.css — Times Clone Core Stylesheet
 * CSS Variables (Design Tokens), Reset, Typography, Base Layout Utilities
 * Mobile-first approach: base styles for mobile, @media (min-width:...) for larger screens.
 *
 * @package times-clone
 */

/* ============================================================
 * 1. DESIGN TOKENS — CSS VARIABLES
 * ============================================================ */
:root {
    /* Brand Colors */
    --color-primary:        #d93407;   /* Warna Logo (Merah Oranye) */
    --color-primary-dark:   #b32805;   /* Hover state merah oranye */
    --color-secondary:      #832D81;   /* Ungu tua/magenta */
    --color-navy:           #0d1b2a;   /* Footer & ticker background */
    --color-navy-light:     #162236;   /* Footer secondary bg */

    /* Surface & Background */
    --color-bg:             #f0f2f5;   /* Page background */
    --color-surface:        #ffffff;   /* Card background */
    --color-surface-hover:  #f8f9fa;   /* Card hover */

    /* Text */
    --color-text:           #1a1a2e;   /* Body / heading text */
    --color-text-secondary: #4b5563;   /* Subheading / lead */
    --color-muted:          #6b7280;   /* Meta, timestamps */
    --color-muted-light:    #9ca3af;   /* Placeholder text */

    /* Borders */
    --color-border:         #e5e7eb;
    --color-border-dark:    #d1d5db;

    /* Header */
    --header-tier1-bg:      linear-gradient(90deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    --header-tier2-bg:      var(--color-primary-dark);   /* Ungu gelap untuk nav bawah */
    --header-tier2-text:    #ffffff;

    /* Typography */
    --font-heading:         'Plus Jakarta Sans', system-ui, sans-serif;
    --font-body:            'Inter', system-ui, sans-serif;

    /* Font sizes (mobile base) */
    --text-xs:   0.75rem;   /* 12px */
    --text-sm:   0.875rem;  /* 14px */
    --text-base: 1rem;      /* 16px */
    --text-lg:   1.125rem;  /* 18px */
    --text-xl:   1.25rem;   /* 20px */
    --text-2xl:  1.5rem;    /* 24px */
    --text-3xl:  1.875rem;  /* 30px */
    --text-4xl:  2.25rem;   /* 36px */

    /* Spacing */
    --space-1:  0.25rem;
    --space-2:  0.5rem;
    --space-3:  0.75rem;
    --space-4:  1rem;
    --space-5:  1.25rem;
    --space-6:  1.5rem;
    --space-8:  2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border Radius */
    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --radius-xl:  16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.10), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg:  0 10px 30px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);

    /* Transitions */
    --transition-fast:   150ms ease;
    --transition-base:   250ms ease;
    --transition-slow:   400ms ease;

    /* Layout */
    --container-max:    1200px;
    --container-pad:    var(--space-4);
    --header-height:    108px;  /* Approx total 2-tier header height */
}

/* ============================================================
 * 2. CSS RESET & BASE
 * ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, video, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary);
}

ul, ol {
    list-style: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* Accessibility: Screen reader only */
.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Focus visible ring */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ============================================================
 * 3. TYPOGRAPHY
 * ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.25;
    color: var(--color-text);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); }

@media (min-width: 768px) {
    h1 { font-size: var(--text-3xl); }
    h2 { font-size: var(--text-2xl); }
    h3 { font-size: var(--text-xl); }
}

@media (min-width: 1024px) {
    h1 { font-size: var(--text-4xl); }
    h2 { font-size: var(--text-3xl); }
}

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

/* ============================================================
 * 4. LAYOUT UTILITIES
 * ============================================================ */

/* Container */
.container {
    width: 100%;
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--container-pad);
}

@media (min-width: 768px) {
    .container {
        padding-inline: var(--space-6);
    }
}

/* Main Site Content Area (below sticky header) */
#main-content {
    min-height: 60vh;
    padding-block: var(--space-6);
}

/* Section spacing */
.section {
    margin-bottom: var(--space-10);
}

@media (min-width: 768px) {
    .section {
        margin-bottom: var(--space-16);
    }
}

/* Section heading with red left accent */
.section-heading {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--color-border);
}

.section-heading::before {
    content: '';
    display: block;
    width: 4px;
    height: 1.25em;
    background-color: var(--color-primary);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .section-heading {
        font-size: var(--text-xl);
    }
}

/* ============================================================
 * 5. CARD — BASE COMPONENT
 * ============================================================ */
.news-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
    display: flex;
    flex-direction: column;
}

.news-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.news-card__thumb {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background-color: var(--color-border);
}

.news-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.news-card:hover .news-card__thumb img {
    transform: scale(1.04);
}

.news-card__body {
    padding: var(--space-4);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.news-card__category {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    background-color: rgba(196, 18, 48, 0.08);
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
}

.news-card__title {
    font-family: var(--font-heading);
    font-size: var(--text-base);
    font-weight: 700;
    line-height: 1.35;
    color: var(--color-text);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card__title a:hover {
    color: var(--color-primary);
}

.news-card__excerpt {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.news-card__meta {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-xs);
    color: var(--color-muted);
    margin-top: auto;
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}

.news-card__meta svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

.news-card__meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================================
 * 6. CATEGORY TAG (inline)
 * ============================================================ */
.cat-tag {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #fff;
    background-color: var(--color-primary);
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    line-height: 1.4;
}

/* ============================================================
 * 7. VIEW COUNTER BADGE (overlay on thumbnails)
 * ============================================================ */
.view-badge {
    position: absolute;
    bottom: var(--space-2);
    right: var(--space-2);
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: var(--text-xs);
    padding: 2px var(--space-2);
    border-radius: var(--radius-full);
    backdrop-filter: blur(4px);
}

.view-badge svg {
    width: 12px;
    height: 12px;
}

/* ============================================================
 * 8. BREADCRUMBS
 * ============================================================ */
.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-1);
    font-size: var(--text-sm);
    color: var(--color-muted);
    margin-bottom: var(--space-5);
}

.breadcrumbs a {
    color: var(--color-primary);
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.bc-sep {
    color: var(--color-muted-light);
}

/* ============================================================
 * 9. PAGINATION
 * ============================================================ */
.nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    margin-top: var(--space-8);
}

.page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding-inline: var(--space-3);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 600;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    transition: all var(--transition-fast);
}

.page-numbers:hover,
.page-numbers.current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* ============================================================
 * 10. LOAD MORE BUTTON
 * ============================================================ */
.load-more-wrap {
    text-align: center;
    margin-top: var(--space-8);
}

.btn-load-more {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-8);
    background: var(--color-primary);
    color: #fff;
    font-family: var(--font-heading);
    font-size: var(--text-sm);
    font-weight: 700;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-primary);
    transition: all var(--transition-base);
    cursor: pointer;
}

.btn-load-more:hover {
    background: transparent;
    color: var(--color-primary);
}

.btn-load-more:disabled,
.btn-load-more.is-loading {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-load-more .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tc-spin 0.7s linear infinite;
    display: none;
}

.btn-load-more.is-loading .spinner {
    display: block;
}

@keyframes tc-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
 * 11. POST GRID (generic)
 * ============================================================ */
.post-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
}

@media (min-width: 600px) {
    .post-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .post-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================================
 * 12. SKIP LINK (Accessibility)
 * ============================================================ */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    z-index: 9999;
    padding: var(--space-2) var(--space-4);
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-md);
    font-weight: 700;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: var(--space-4);
    color: #fff;
}

/* ============================================================
 * 13. EMPTY STATE
 * ============================================================ */
.no-posts {
    text-align: center;
    padding: var(--space-16) var(--space-4);
    color: var(--color-muted);
}

.no-posts__icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
}

.no-posts__title {
    font-size: var(--text-xl);
    margin-bottom: var(--space-2);
}
