/**
 * POSTAL RESOURCES PAGE STYLES
 * Matches Country Index page aesthetic — hero, sticky A-Z nav, clean table
 */

/* ===== HERO SECTION ===== */
.postal-hero {
    position: relative;
    padding: var(--space-7) 0 var(--space-5);
    background: linear-gradient(135deg, var(--color-gray-900) 0%, #1a1a1a 50%, var(--color-gray-900) 100%);
    color: var(--color-white);
    text-align: center;
}

.postal-hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    font-family: var(--font-display, 'Crimson Pro', Georgia, serif);
    line-height: 1.2;
    margin-bottom: var(--space-3);
    color: var(--color-white);
    letter-spacing: -0.02em;
}

.postal-hero__subtitle {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-relaxed);
    opacity: 0.85;
    max-width: 700px;
    margin: 0 auto;
    color: var(--color-white);
}

/* ===== A-Z NAVIGATION =====
 * Base styles now in css/components/az-nav.css
 * Full-width spread handled globally in az-nav.css.
 */

/* ===== PAGE SECTION ===== */
.postal-resources-section {
    padding: var(--space-6) 0;
    background: var(--color-background);
}

.postal-resources-section .container {
    max-width: 1000px;
}

/* Table section directly after sticky A-Z nav — no extra top padding */
.postal-resources-section.postal-resources-section--table {
    padding-top: 0;
}

/* ===== TYPOGRAPHY ===== */
.postal-resources-section h3 {
    font-family: var(--font-display, 'Crimson Pro', Georgia, serif);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 3px solid var(--color-accent);
    display: inline-block;
}

/* ===== LINKS ===== */
/* :where() gives zero specificity so shared components (az-nav, prev-next-nav)
   are never affected by these page-level link styles */
:where(.postal-resources-section) a {
    color: var(--color-text-primary);
    text-decoration: underline;
    text-decoration-color: var(--color-accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    transition: all var(--transition-fast);
}

:where(.postal-resources-section) a:hover {
    color: var(--color-accent-dark);
    text-decoration-color: var(--color-accent-dark);
}

/* ===== LEGEND TABLE ===== */
.postal-resources-section table[cellpadding="10"] {
    width: auto;
    margin: var(--space-5) auto var(--space-6);
    background: var(--color-gray-100);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.postal-resources-section table[cellpadding="10"] td {
    padding: var(--space-3) var(--space-4);
    vertical-align: middle;
    line-height: var(--line-height-relaxed);
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--color-border);
}

.postal-resources-section table[cellpadding="10"] tr:last-child td {
    border-bottom: none;
}

/* Legend icons — uniform 32px */
.postal-resources-section table[cellpadding="10"] img {
    display: inline-block;
    width: 32px;
    height: 32px;
    max-width: none;
    object-fit: contain;
}

/* Legend flag icon — preserve natural flag aspect */
.postal-resources-section table[cellpadding="10"] img[src*="flags"] {
    width: auto;
    height: 24px;
}

/* Legend Facebook promo — full size, not icon-sized */
.postal-resources-section table[cellpadding="10"] img[src*="ads/facebook"] {
    width: auto;
    height: auto;
    max-width: 200px;
    border-radius: var(--border-radius-md);
}

/* ===== MAIN DATA TABLE ===== */
.postal-resources-section table[border="1"] {
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    border-collapse: separate;
    border-spacing: 0;
    background: var(--color-white);
}

.postal-resources-section table[border="1"] td {
    border: none;
    border-bottom: 1px solid var(--color-border);
    border-right: 1px solid var(--color-gray-100);
    padding: var(--space-3) var(--space-3);
    vertical-align: middle;
    font-size: var(--font-size-sm);
    text-align: center;
}

/* Country name cell — left align text */
.postal-resources-section table[border="1"] td:first-child {
    text-align: left;
}

.postal-resources-section table[border="1"] td:last-child {
    border-right: none;
}

.postal-resources-section table[border="1"] tr:last-child td {
    border-bottom: none;
}

/* Anchor scroll offset for sticky nav + sticky table header */
.postal-resources-section table[border="1"] td a[name] {
    scroll-margin-top: calc(var(--table-header-top, 120px) + 60px);
}

/* Header row — light gray matching country-table th */
.postal-resources-section table[border="1"] tr[style*="font-weight: bold"] td {
    background: var(--color-gray-100);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-3) var(--space-3);
    border-bottom: 2px solid var(--color-border);
    border-right: 1px solid var(--color-gray-200);
}

.postal-resources-section table[border="1"] tr[style*="font-weight: bold"] td:last-child {
    border-right: none;
}

/* Countries index row inside table — HIDDEN (replaced by sticky nav) */
.postal-resources-section table[border="1"] td[colspan="12"] {
    display: none;
}

.postal-resources-section table[border="1"] tr:has(> td[colspan="12"]) {
    display: none;
}

/* Data rows hover */
.postal-resources-section table[border="1"] tr:hover td {
    background: var(--color-background-alt);
}

.postal-resources-section table[border="1"] tr[style*="font-weight: bold"]:hover td {
    background: var(--color-gray-100);
}

/* ===== ICONS — Uniform 40px with object-fit ===== */
.postal-resources-section table[border="1"] img {
    display: inline-block;
    width: 40px;
    height: 40px;
    max-width: none; /* override base.css max-width:100% that squeezes icons */
    object-fit: contain;
    transition: transform 0.2s ease;
}

.postal-resources-section table[border="1"] img:hover {
    transform: scale(1.1);
}

/* Flag cell — tighter padding so flag fills the space */
.postal-resources-section table[border="1"] td:nth-child(2) {
    padding: 4px;
}

/* Flag images — rectangular, preserve aspect ratio */
.postal-resources-section table[border="1"] img[src*="flags"] {
    width: auto;
    height: 40px;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    border: 1px solid var(--color-border);
}

/* ===== STICKY TABLE HEADER ===== */
.postal-resources-section .postal-table-head tr[style*="font-weight: bold"]:not(:has(> td[colspan="12"])) td {
    position: sticky;
    top: var(--table-header-top, 120px);
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* ===== LETTER SECTION HEADERS ===== */
/* First country of each letter — style the big letter */
.postal-resources-section table[border="1"] td big {
    font-family: var(--font-display, 'Crimson Pro', Georgia, serif);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-accent-dark);
}

/* ===== BACK TO INDEX BUTTON ===== */
.postal-resources-section .button {
    display: inline-block;
    padding: 4px 12px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    outline: none;
    color: var(--color-white);
    background-color: var(--color-primary);
    border: none;
    border-radius: var(--border-radius-full);
    transition: all var(--transition-fast);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.postal-resources-section .button:hover {
    background-color: var(--color-accent);
    color: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.postal-resources-section .button:active {
    transform: translateY(0);
}

/* ===== REFERENCES SECTION ===== */
.postal-resources-section ol {
    padding-left: var(--space-5);
    line-height: 1.8;
    margin: var(--space-4) 0 var(--space-6);
}

.postal-resources-section ol li {
    margin-bottom: var(--space-2);
    font-size: var(--font-size-sm);
}

/* ===== FACEBOOK PROMO TABLE ===== */
.postal-resources-section table[align="right"][width="200px"] {
    float: right;
    width: 200px;
    margin: 0 0 var(--space-5) var(--space-5);
    border: none;
}

.postal-resources-section table[align="right"][width="200px"] td {
    border: none;
    padding: 0;
}

.postal-resources-section table[align="right"][width="200px"] img {
    max-height: none;
    width: 200px;
    height: auto;
    max-width: none;
    object-fit: unset;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease;
}

.postal-resources-section table[align="right"][width="200px"] img:hover {
    transform: scale(1.02);
}

/* ===== GOOGLE ADS CONTAINERS ===== */
.postal-resources-section .adsbygoogle {
    margin: var(--space-5) 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    /* overflow on wrapper only — keeps .az-navigation sticky */
    .postal-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Disable sticky header when table scrolls horizontally */
    .postal-resources-section .postal-table-head tr[style*="font-weight: bold"] td {
        position: static;
    }
}

@media (max-width: 768px) {
    .postal-hero {
        padding: var(--space-5) 0 var(--space-4);
    }

    .postal-hero h1 {
        font-size: clamp(1.25rem, 5vw, 1.75rem);
    }

    .postal-resources-section {
        padding: var(--space-5) 0;
    }

    .postal-resources-section table[cellpadding="10"] {
        font-size: var(--font-size-xs);
    }

    .postal-resources-section table[align="right"][width="200px"] {
        float: none;
        width: 100%;
        margin: var(--space-4) 0;
        text-align: center;
    }
}


/* ===== PRINT ===== */
@media print {
    .postal-hero {
        background: var(--color-white) !important;
        color: var(--color-primary) !important;
        padding: var(--space-4) 0;
    }

    .postal-hero h1 {
        color: var(--color-primary) !important;
    }

    .postal-resources-section table[border="1"] {
        page-break-inside: auto;
    }

    .postal-resources-section table[border="1"] tr {
        page-break-inside: avoid;
    }
}