/**
 * INDEX PAGE STYLES
 * Shared styles for A-Z index pages: country index + stamps description index.
 * Both pages share the same structure: hero + A-Z nav + sidebar float tables +
 * main content table with flag/country/description columns.
 *
 * Scoping: .country-index-content (country/index.html)
 *          .stamps-index-content  (description/stamps/index.html)
 *
 * Shared components (loaded via main.css):
 *   - page-hero.css: Hero section
 *   - az-nav.css: A-Z letter navigation
 *   - index-letter-headers.css: Letter headers, anchor offsets, back-to-index
 */

/* =====================================================================
   COUNTRY INDEX
   ===================================================================== */

/* ===== MAIN CONTENT ===== */
.country-index-content {
    padding: var(--space-6) 0;
    background: var(--color-background);
}

/* Floating sidebar tables (preview images) */
.country-index-content table[align="right"] {
    float: right;
    width: 300px !important;
    margin: 10px !important;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    padding: var(--space-3);
    box-shadow: var(--shadow-sm);
}

.country-index-content table[align="right"] img {
    max-width: 100%;
    height: auto !important;
    width: auto !important;
    max-height: 200px;
    display: block;
    margin: 0 auto var(--space-2);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--color-border);
}

.country-index-content table[align="right"] td {
    padding: var(--space-2);
    text-align: center;
}

.country-index-content table[align="right"] small {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    display: block;
    text-align: center;
    line-height: var(--line-height-normal);
}

.country-index-content table[align="right"] em {
    font-style: italic;
}

.country-index-content table[align="right"] a {
    color: var(--color-primary);
    text-decoration: none;
}

.country-index-content table[align="right"] a:hover {
    text-decoration: underline;
}

/* Main country table (uses width="600px" attribute) */
.country-index-content table[width="600px"],
.country-index-content table.country-list {
    width: 600px;
    max-width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    margin-bottom: var(--space-3);
}

.country-index-content table[width="600px"] td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-secondary);
}

.country-index-content table[width="600px"] tr:last-child td {
    border-bottom: none;
}

.country-index-content table[width="600px"] tr:hover td {
    background: var(--color-background-alt);
}

/* Flag images in country table */
.country-index-content table[width="600px"] td:first-child {
    width: 50px !important;
    text-align: center;
    padding: var(--space-2);
}

.country-index-content table[width="600px"] td:first-child img {
    width: 40px;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border);
}

/* Country name column */
.country-index-content table[width="600px"] td:nth-child(2) {
    width: 160px !important;
    font-weight: var(--font-weight-medium);
}

.country-index-content table[width="600px"] td:nth-child(2) a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: var(--font-weight-bold);
}

.country-index-content table[width="600px"] td:nth-child(2) a:hover {
    color: var(--color-accent-dark);
    text-decoration: underline;
}

/* Description column */
.country-index-content table[width="600px"] td:nth-child(3) {
    width: auto !important;
}

.country-index-content table[width="600px"] td:nth-child(3) a {
    color: var(--color-primary);
    text-decoration: none;
}

.country-index-content table[width="600px"] td:nth-child(3) a:hover {
    text-decoration: underline;
}

/* Bottom navigation bar (legacy inline nav at end of page) */
.country-index-content #main_nav_list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-4) 0;
    margin: var(--space-4) 0 0;
    border-top: 1px solid var(--color-border);
}

.country-index-content #main_nav_list li {
    margin: 0;
}

.country-index-content .main_nav_item,
.country-index-content .main_nav_active_item {
    display: inline-block;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    text-decoration: none;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    background: var(--color-white);
    transition: all var(--transition-fast);
}

.country-index-content .main_nav_item:hover,
.country-index-content .main_nav_active_item:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white);
    text-decoration: none;
}

.country-index-content .main_nav_active_item {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-primary);
}

/* ===== LETTER SECTION ===== */
.letter-section {
    margin-bottom: var(--space-7);
    scroll-margin-top: 140px;
}

.letter-section__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 2px solid var(--color-accent);
}

.letter-section__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--color-primary);
    color: var(--color-white);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    border-radius: var(--border-radius-sm);
}

.letter-section__title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    margin: 0;
}

.letter-section__count {
    margin-left: auto;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    background: var(--color-background-alt);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--border-radius-full);
}

/* ===== COUNTRY TABLE ===== */
.country-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    margin-bottom: var(--space-4);
}

.country-table th {
    background: var(--color-gray-100);
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    border-bottom: 2px solid var(--color-border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.country-table th:first-child {
    width: 60px;
    text-align: center;
}

.country-table th:nth-child(2) {
    width: 200px;
}

.country-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-secondary);
}

.country-table tr:last-child td {
    border-bottom: none;
}

.country-table tr:hover td {
    background: var(--color-background-alt);
}

/* Flag Column */
.country-table td:first-child {
    text-align: center;
    padding: var(--space-3);
}

.country-table td:first-child img {
    width: 40px;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border);
}

/* Country Name Column */
.country-table td:nth-child(2) {
    font-weight: var(--font-weight-medium);
}

.country-table td:nth-child(2) a {
    color: var(--color-primary);
    text-decoration: none;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
}

.country-table td:nth-child(2) a:hover {
    color: var(--color-accent-dark);
    text-decoration: underline;
}

/* Description Column */
.country-table td:nth-child(3) {
    color: var(--color-text-secondary);
}

.country-table td:nth-child(3) a {
    color: var(--color-primary);
    text-decoration: none;
}

.country-table td:nth-child(3) a:hover {
    text-decoration: underline;
}

.country-table td:nth-child(3) em {
    font-style: italic;
}

/* ===== COUNTRY CARDS (Alternative Layout) ===== */
.country-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-4);
}

.country-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    padding: var(--space-4);
    transition: all var(--transition-fast);
}

.country-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.country-card__header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.country-card__flag {
    width: 48px;
    height: auto;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
}

.country-card__name {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}

.country-card__name a {
    color: inherit;
    text-decoration: none;
}

.country-card__name a:hover {
    color: var(--color-primary);
}

.country-card__description {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: var(--line-height-relaxed);
}

.country-card__description a {
    color: var(--color-primary);
    text-decoration: none;
}

.country-card__description a:hover {
    text-decoration: underline;
}

/* ===== BACK TO INDEX BUTTON ===== */
.back-to-index {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--color-primary);
    color: var(--color-white);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    text-decoration: none;
    border-radius: var(--border-radius-full);
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-fast);
    z-index: var(--z-fixed);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.back-to-index--visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-index:hover {
    background: #1a1a1a;
    transform: translateY(-2px);
    text-decoration: none;
}


/* =====================================================================
   STAMPS DESCRIPTION INDEX
   ===================================================================== */

/* ===== INTRO SECTION (descriptive text below hero) ===== */
.stamps-index-intro {
    padding: var(--space-4) 0 var(--space-3);
    background: var(--color-background-alt, #f5f5f5);
    border-bottom: 1px solid var(--color-border);
}

.stamps-index-intro__content {
    max-width: 850px;
    margin: 0 auto;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-secondary);
}

.stamps-index-intro ul {
    text-align: left;
    max-width: 700px;
    margin: var(--space-2) auto;
    padding-left: 1.75rem;
}

.stamps-index-intro li {
    margin-bottom: 0.35rem;
    line-height: 1.65;
}

/* Hide Google Ads markup inside intro cleanly */
.stamps-index-intro .adsbygoogle {
    margin: var(--space-3) auto;
}

/* ===== MAIN CONTENT ===== */
.stamps-index-content {
    padding: var(--space-6) 0;
    background: var(--color-background);
}

.stamps-index-content .container.content-page {
    max-width: 1000px;
    text-align: left;
}

/* Floating sidebar tables (preview images) */
.stamps-index-content table[align="right"] {
    float: right;
    width: 300px !important;
    margin: 10px !important;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    padding: var(--space-3);
    box-shadow: var(--shadow-sm);
}

.stamps-index-content table[align="right"] img {
    max-width: 100%;
    height: auto !important;
    width: auto !important;
    max-height: 200px;
    display: block;
    margin: 0 auto var(--space-2);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--color-border);
}

.stamps-index-content table[align="right"] td {
    padding: var(--space-2);
    text-align: center;
    border-bottom: none;
}

.stamps-index-content table[align="right"] small {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    display: block;
    text-align: center;
    line-height: var(--line-height-normal);
}

.stamps-index-content table[align="right"] em {
    font-style: italic;
}

.stamps-index-content table[align="right"] a {
    color: var(--color-primary);
    text-decoration: none;
}

.stamps-index-content table[align="right"] a:hover {
    text-decoration: underline;
}

/* Main content table (uses width="700px" attribute) —
   shrunk to 600px so it fits beside the 300px sidebar within the 1000px container */
.stamps-index-content table[width="700px"] {
    width: 600px !important;
    max-width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    margin-bottom: var(--space-3);
}

.stamps-index-content table[width="700px"] td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    font-size: var(--font-size-base);
    line-height: var(--line-height-relaxed);
    color: var(--color-text-secondary);
}

.stamps-index-content table[width="700px"] tr:last-child td {
    border-bottom: none;
}

.stamps-index-content table[width="700px"] tr:hover td {
    background: var(--color-background-alt);
}

/* Flag images in content table */
.stamps-index-content table[width="700px"] td:first-child {
    width: 50px !important;
    text-align: center;
    padding: var(--space-2);
}

.stamps-index-content table[width="700px"] td:first-child img {
    width: 40px;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border);
}

/* Country name column */
.stamps-index-content table[width="700px"] td:nth-child(2) {
    width: 120px !important;
    font-weight: var(--font-weight-medium);
}

.stamps-index-content table[width="700px"] td:nth-child(2) a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: var(--font-weight-bold);
}

.stamps-index-content table[width="700px"] td:nth-child(2) a:hover {
    color: var(--color-accent-dark);
    text-decoration: underline;
}

/* Description/articles column */
.stamps-index-content table[width="700px"] td:nth-child(3) {
    width: auto !important;
}

.stamps-index-content table[width="700px"] td:nth-child(3) a {
    color: var(--color-primary);
    text-decoration: none;
}

.stamps-index-content table[width="700px"] td:nth-child(3) a:hover {
    text-decoration: underline;
}

/* TOC list items inside tables */
.stamps-index-content .toc {
    margin-bottom: 0.25rem;
}

/* Also handle tables with width="100%" (empty letter sections) */
.stamps-index-content table[width="100%"] {
    max-width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--space-3);
}

/* Content links — :where() prevents leaking into shared components */
:where(.stamps-index-content) a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

:where(.stamps-index-content) a:hover {
    color: var(--color-accent-dark);
    text-decoration: underline;
}


/* =====================================================================
   RESPONSIVE — BOTH INDEX PAGES
   ===================================================================== */

@media (max-width: 768px) {
    /* --- Country Index --- */
    .country-table {
        display: block;
        overflow-x: auto;
    }

    .country-table th,
    .country-table td {
        padding: var(--space-2) var(--space-3);
    }

    .country-table td:first-child img {
        width: 32px;
    }

    .letter-section__badge {
        width: 40px;
        height: 40px;
        font-size: var(--font-size-xl);
    }

    .back-to-index {
        bottom: var(--space-4);
        right: var(--space-4);
        padding: var(--space-2) var(--space-3);
    }

    .country-index-content table[align="right"] {
        float: none !important;
        width: 100% !important;
        margin: var(--space-3) 0 !important;
    }

    .country-index-content table[width="600px"] {
        width: 100% !important;
        display: block;
        overflow-x: auto;
    }

    .country-index-content table[width="600px"] td {
        padding: var(--space-2);
        font-size: var(--font-size-xs);
    }

    .country-index-content table[width="600px"] td:first-child img {
        width: 30px;
    }

    .country-index-content table[width="600px"] td:nth-child(2) {
        width: 100px !important;
    }

    /* --- Stamps Index --- */
    .stamps-index-intro {
        padding: var(--space-3) 0 var(--space-2);
    }

    .stamps-index-content table[align="right"] {
        float: none !important;
        width: 100% !important;
        margin: var(--space-3) 0 !important;
    }

    .stamps-index-content table[align="right"] img {
        max-height: none;
    }

    .stamps-index-content table[width="700px"] {
        width: 100% !important;
        display: block;
        overflow-x: auto;
    }

    .stamps-index-content table[width="700px"] td {
        padding: var(--space-2);
        font-size: var(--font-size-xs);
    }

    .stamps-index-content table[width="700px"] td:first-child img {
        width: 30px;
    }

    .stamps-index-content table[width="700px"] td:nth-child(2) {
        width: 80px !important;
    }
}

@media (max-width: 576px) {
    .letter-section__header {
        flex-wrap: wrap;
    }

    .letter-section__count {
        width: 100%;
        margin-left: 0;
        margin-top: var(--space-2);
        text-align: center;
    }

    /* Stack table on very small screens */
    .country-table thead {
        display: none;
    }

    .country-table tr {
        display: block;
        margin-bottom: var(--space-3);
        border: 1px solid var(--color-border);
        border-radius: var(--border-radius-md);
        background: var(--color-white);
    }

    .country-table td {
        display: block;
        padding: var(--space-2) var(--space-3);
        border-bottom: none;
    }

    .country-table td:first-child {
        text-align: left;
        padding-bottom: 0;
    }

    .country-table td:first-child img {
        width: 32px;
    }

    .country-table td:nth-child(2) {
        padding-top: 0;
        padding-bottom: var(--space-2);
        border-bottom: 1px solid var(--color-border);
    }
}

/* ===== PRINT ===== */
@media print {
    .back-to-index {
        display: none !important;
    }

    .country-table {
        page-break-inside: auto;
    }

    .country-table tr {
        page-break-inside: avoid;
    }

    .letter-section {
        page-break-before: auto;
    }
}
