:root {
    --stroke-duration: 1.5s;
    --fill-duration: 0.8s;
    --transition-duration: 0.8s;
    --morph-duration: 1.2s;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: white;
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: black;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Loading Screen */
.loader-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: black;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.6s ease-out;
}

.loader-screen.background-fade {
    opacity: 0;
}

.loader-screen.hide {
    display: none;
}

.svg-wrapper {
    width: 400px;
    height: auto;
    position: relative;
    transition: all var(--morph-duration) cubic-bezier(0.4, 0, 0.2, 1);
}

.svg-wrapper.morphing {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
}

svg {
    width: 100%;
}

svg text {
    stroke: white;
    stroke-width: 1;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    fill: transparent;
    animation: drawStroke var(--stroke-duration) ease-out forwards;
    transition: all var(--morph-duration) cubic-bezier(0.4, 0, 0.2, 1);
}

.fill-text {
    stroke: transparent;
    fill: white;
    clip-path: polygon(0 100%, 100% 100%, 100% 100%, 0 100%);
    animation: fillText var(--fill-duration) ease-in-out var(--stroke-duration) forwards;
}

@keyframes drawStroke {
    0% { stroke-dashoffset: 600; }
    100% { stroke-dashoffset: 0; }
}

@keyframes fillText {
    0% { clip-path: polygon(0 100%, 100% 100%, 100% 100%, 0 100%); }
    100% { clip-path: polygon(0 0%, 100% 0%, 100% 100%, 0 100%); }
}

svg text.morphing {
    fill: white;
    stroke: transparent;
}

svg text.fade-to-black {
    fill: black;
    stroke: transparent;
}

/* Main Content */
#main-content {
    opacity: 0;
    transition: opacity var(--transition-duration) ease-in-out;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#main-content.show {
    opacity: 1;
}

body.loaded {
    overflow-y: auto;
}

/* Navigation */
.menu-bar {
    width: 100%;
    height: 70px;
    background-color: white;
    border-bottom: 1px solid black;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-placeholder {
    font-family: 'Poppins', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: black;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.nav-links {
    display: flex;
    gap: 30px;
    align-items: center;
}

.nav-link {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: black;
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: black;
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* Main */
main {
    flex: 1;
    padding: 0;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    overflow-y: visible;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 60px 20px 40px;
    border-bottom: 1px solid #e0e0e0;
}

#policy-title {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: black;
    margin: 0 0 10px 0;
    text-align: center;
    opacity: 0;
    transition: opacity 0.4s ease-in;
    position: relative;
}

#policy-title.show {
    opacity: 1;
}

.hero-subtitle {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 300;
    color: #444;
    margin-bottom: 8px;
}

.hero-date {
    font-size: 0.9rem;
    color: #666;
}

.pdf-button {
    display: inline-block;
    padding: 10px 24px;
    background-color: black;
    color: white;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid black;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 16px;
}

.pdf-button:hover {
    background-color: white;
    color: black;
}

/* Section Blocks */
.section-block {
    padding: 40px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.section-block:last-child {
    border-bottom: none;
}

/* Typography */
h1 {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: black;
    margin: 0 0 15px 0;
    text-align: center;
}

h2 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
}

p {
    margin-bottom: 1rem;
}

ul {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

a {
    color: black;
}

/* Country Grid */
.country-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.country-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border: 1px solid black;
    text-decoration: none;
    color: black;
    transition: all 0.25s ease;
    background: white;
}

.country-card:hover {
    background-color: black;
    color: white;
}

.country-card:hover .platform-url,
.country-card:hover .platform-law {
    color: #ccc;
}

.country-card:hover .country-flag {
    background-color: white;
    color: black;
}

.country-flag {
    width: 48px;
    height: 48px;
    background-color: black;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.country-info {
    flex: 1;
    min-width: 0;
}

.country-info h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.platform-name {
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    margin: 0 0 2px 0;
}

.platform-url {
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    color: #666;
    margin: 0 0 2px 0;
    transition: color 0.25s ease;
}

.platform-law {
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    color: #888;
    margin: 0;
    transition: color 0.25s ease;
}

.card-arrow {
    font-size: 1.2rem;
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-8px);
    transition: all 0.25s ease;
}

.country-card:hover .card-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Country Detail Sections */
.country-detail {
    border: 1px solid black;
    padding: 24px;
    margin-top: 20px;
}

.country-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.country-detail-header h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
}

.policy-link-btn {
    display: inline-block;
    padding: 8px 18px;
    background-color: black;
    color: white;
    text-decoration: none;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid black;
    transition: all 0.3s ease;
}

.policy-link-btn:hover {
    background-color: white;
    color: black;
}

.policy-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.policy-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.policy-table td:first-child {
    width: 180px;
    white-space: nowrap;
}

.policy-table a {
    color: black;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.country-detail > p {
    font-size: 0.9rem;
    color: #333;
    margin-bottom: 0;
}

/* Contact Grid */
.contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.contact-item {
    border: 1px solid black;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.contact-item strong {
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
}

.contact-item a {
    font-size: 0.9rem;
    color: black;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

/* Footer */
.footer-bar {
    width: 100%;
    height: 70px;
    background-color: white;
    border-top: 1px solid black;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    margin-top: auto;
}

.footer-links {
    display: flex;
    gap: 40px;
    align-items: center;
}

.footer-link {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: black;
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.footer-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: black;
    transition: width 0.3s ease;
}

.footer-link:hover::after {
    width: 100%;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .menu-bar {
        padding: 0 16px;
        height: 60px;
    }

    .logo-placeholder {
        font-size: 16px;
    }

    .nav-links {
        gap: 16px;
    }

    .nav-link {
        font-size: 12px;
    }

    .hero-section {
        padding: 40px 16px 30px;
    }

    #policy-title, h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.2rem;
    }

    h3 {
        font-size: 1rem;
    }

    .section-block {
        padding: 30px 16px;
    }

    .country-grid {
        grid-template-columns: 1fr;
    }

    .country-detail {
        padding: 16px;
    }

    .country-detail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .policy-table td:first-child {
        width: 120px;
    }

    .contact-grid {
        grid-template-columns: 1fr;
    }

    .footer-links {
        gap: 16px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .footer-link {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .menu-bar {
        padding: 0 10px;
    }

    .nav-links {
        gap: 10px;
    }

    .nav-link {
        font-size: 11px;
    }

    .logo-placeholder {
        font-size: 14px;
    }

    #policy-title, h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1rem;
    }

    h3 {
        font-size: 0.95rem;
    }

    .section-block {
        padding: 20px 10px;
    }

    .hero-section {
        padding: 30px 10px 20px;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .country-card {
        padding: 14px;
    }

    .country-flag {
        width: 40px;
        height: 40px;
        font-size: 12px;
    }

    .policy-table td {
        display: block;
        padding: 4px 0;
    }

    .policy-table td:first-child {
        width: auto;
        font-size: 0.8rem;
        padding-top: 10px;
    }

    .policy-table tr {
        display: block;
        border-bottom: 1px solid #eee;
    }

    .footer-links {
        gap: 10px;
    }

    .footer-link {
        font-size: 11px;
    }
}

/* Print / PDF Styles */
@media print {
    /* Hide non-content elements */
    .loader-screen,
    .menu-bar,
    .footer-bar,
    .pdf-button,
    .card-arrow,
    .policy-link-btn {
        display: none !important;
    }

    /* Reset layout */
    body {
        background: white;
        color: black;
        font-size: 11pt;
        line-height: 1.5;
    }

    #main-content {
        opacity: 1 !important;
    }

    main {
        max-width: 100%;
        padding: 0;
    }

    /* Hero */
    .hero-section {
        padding: 0 0 20px;
        border-bottom: 2px solid black;
    }

    #policy-title {
        opacity: 1 !important;
        font-size: 22pt;
    }

    .hero-subtitle {
        font-size: 12pt;
        color: black;
    }

    .hero-date {
        font-size: 10pt;
        color: black;
    }

    /* Sections */
    .section-block {
        padding: 16px 0;
        border-bottom: 1px solid #ccc;
    }

    h2 {
        font-size: 14pt;
        margin-top: 18px;
        page-break-after: avoid;
    }

    h3 {
        font-size: 12pt;
        page-break-after: avoid;
    }

    p, ul, li, table {
        page-break-inside: avoid;
    }

    /* Country grid - linearise for print */
    .country-grid {
        display: block;
    }

    .country-card {
        display: flex;
        border: 1px solid #999;
        padding: 10px 14px;
        margin-bottom: 8px;
        page-break-inside: avoid;
        text-decoration: none;
        color: black;
    }

    .country-card:hover {
        background-color: white;
        color: black;
    }

    .country-flag {
        width: 36px;
        height: 36px;
        font-size: 10pt;
        background-color: black;
        color: white;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .platform-url, .platform-law {
        color: #333 !important;
    }

    /* Country detail sections */
    .country-detail {
        border: 1px solid #999;
        padding: 14px;
        page-break-inside: avoid;
    }

    .country-detail-header {
        flex-direction: row;
    }

    .policy-table {
        font-size: 10pt;
    }

    .policy-table td {
        border-bottom: 1px solid #ddd;
        padding: 5px 8px;
    }

    /* Links - show URLs in print */
    a[href^="mailto:"]::after {
        content: none;
    }

    .policy-table a::after,
    .country-detail a[href^="http"]::after {
        content: none;
    }

    /* Contact grid */
    .contact-grid {
        display: block;
    }

    .contact-item {
        display: inline-block;
        width: 48%;
        vertical-align: top;
        border: 1px solid #999;
        padding: 10px;
        margin-bottom: 8px;
        page-break-inside: avoid;
    }

    /* Page setup */
    @page {
        margin: 1.5cm 2cm;
        size: A4;
    }

    /* Header on first page */
    .hero-section::before {
        content: "policy.taptic.org";
        display: block;
        font-family: 'Poppins', sans-serif;
        font-size: 9pt;
        color: #666;
        text-align: right;
        margin-bottom: 10px;
    }
}
