/* Basic styles for mobile-first design */

*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --primary-color: #0056b3;
    --secondary-color: #007bff;
    --text-color: #333;
    --background-color: #f8f9fa;
    --border-color: #dee2e6;
    --light-gray: #6c757d;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    margin: 0;
    padding: 0;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
    box-sizing: border-box; /* Include padding in element's total width and height */
}

h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

h1 { font-size: 2em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.17em; }

a {
    color: var(--secondary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Header (container width, rounded corners) */
.site-header {
    padding: 0.6rem 0 0 0;
}
.header-container {
    position: relative;
}
.header-surface {
    background-color: transparent;
    color: white;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.14);
    padding: 0.6rem 0.9rem 0.6rem 0.9rem;
    overflow: visible; /* allow banner to extend */
    position: relative;
    z-index: 0;
}
.header-surface::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: var(--primary-color);
    border-radius: 16px;
    z-index: 0;
}
.header-surface > * {
    position: relative;
    z-index: 2;
}
.header-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

/* Brand (globe + search placeholder) */
.header-left {
    display: flex;
    align-items: center;
    gap: 0; /* overlap globe + input like one logo */
    position: relative;
    z-index: 2; /* keep logo above the header shape */
}
.brand-home {
    position: relative;
    z-index: 3; /* float above the input */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.brand-globe {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    transform: translateX(-8px) rotate(-8deg);
    filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.35));
}
/* Brand search removed */

/* Header right SVG (country shape) */
.header-right-shape {
    position: absolute;
    right: 0;
    top: calc(1rem - 28px);
    width: fit-content;
    max-width: min(560px, 68%);
    pointer-events: none;
    z-index: 1; /* above background, below header content */
    opacity: 0.55;

    background: transparent;
    border: none;
    border-radius: 14px;
    padding: 0;
    display: flex;
    justify-content: flex-end;
}
.header-right-shape > div {
    opacity: 1 !important; /* neutralize inline wrapper opacity for header usage */
}
.header-right-shape svg {
    width: auto;
    max-width: 100%;
    height: 145px !important; /* slightly less overlap outside */
    display: block;
    filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.28));
}
.header-right-shape .map-marker circle {
    fill: #ff3b30 !important;
    stroke: rgba(255, 255, 255, 0.9) !important;
}

.main-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.main-nav li {
    margin: 0 0.5rem;
}

.main-nav a {
    color: white;
    padding: 0.5rem 0.8rem;
    display: block;
}

.main-nav a:hover {
    background-color: rgba(255,255,255,0.1);
    border-radius: 4px;
    text-decoration: none;
}

.country-indicator {
    font-size: 0.9em;
    color: rgba(255,255,255,0.8);
    margin-bottom: 0.5rem;
}

.main-footer {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    margin-top: auto; /* Pushes the footer to the bottom */
    text-align: center;
    font-size: 0.9em;
}

/* List styles */
ul.item-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

ul.item-list li {
    background-color: #fff;
    border: 1px solid var(--border-color);
    padding: 0.8rem 1rem;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

ul.item-list li a {
    font-weight: bold;
    color: var(--primary-color);
    flex-grow: 1;
    word-break: break-word;
}

ul.item-list li span {
    color: var(--light-gray);
    font-size: 0.8em;
    margin-left: 1rem;
    /* white-space: nowrap;  Moved to media query for mobile safety */
}

@media (min-width: 600px) {
    ul.item-list li span {
        white-space: nowrap;
    }
}


/* 
   --------------------------------------------------------------
   BENTO GRID SYSTEM
   Modern, responsive grid inspired by dashboard UIs.
   --------------------------------------------------------------
*/
.bento-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: 1 column */
    gap: 2rem; /* Ensure distinct separation */
    margin: 1.5rem 0 2.5rem 0;
    width: 100%;
    /* Enforce a minimum uniform height for rows */
    grid-auto-rows: minmax(8.5rem, auto);
}

/* Card Style */
.bento-grid > div {
    background: #fff;
    border: 1px solid #edf2f7;
    border-radius: 16px; 
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02), 0 1px 3px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Space out label and value */
    
    height: 100%; 
    position: relative; /* Context for absolute backgrounds */
    overflow: hidden; /* Ensure nothing spills out */
}

.bento-grid > div:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px rgba(0,0,0,0.05);
}

/* Typography inside cards */
.bento-grid strong {
    color: #64748b;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem; /* Ensure spacing between title and value */
    display: flex;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    z-index: 2;
}

.bento-grid strong .icon-inline {
    width: 1.25em;
    height: 1.25em;
    opacity: 1;
    color: var(--primary-color);
}

/* Main value styling */
.bento-grid > div span {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
    display: block;
    position: relative;
    z-index: 2;
}

/* Grid Breakpoints */
@media (min-width: 600px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr); /* Tablet: 2 cols */
    }
    
    /* Spanning utility */
    .span-2 {
        grid-column: span 2;
    }
}

@media (min-width: 900px) {
    .bento-grid {
        grid-template-columns: repeat(3, 1fr); /* Desktop: 3 cols */
    }
}

/* Special styling for Area Card in Bento Grid */
.detail-card-area {
    /* overflow handled by parent now */
    z-index: 1;
}

/* Horizontal Layout for Area Card when spanning */
@media (min-width: 600px) {
    .detail-card-area.span-2 {
        flex-direction: row;
        align-items: center;
        padding-right: 2.5rem; /* Balance visual weight */
    }
    
    .detail-card-area.span-2 strong {
        font-size: 1em; /* Slightly larger label */
    }

    .detail-card-area.span-2 span {
        font-size: 2.2rem; /* Hero value */
        margin-top: 0;
    }
}

/* Ensure content stays above background */
.detail-card-area > * {
    position: relative;
    z-index: 2; 
}

/* Adjust shape to be background-only */
.area-card-shape {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.6;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.area-card-shape svg {
    width: 100% !important;
    height: 100% !important;
}

.area-card-shape svg path {
    stroke: rgba(0, 86, 179, 0.4) !important;
    stroke-width: 1px !important;
    fill-opacity: 0.05 !important;
}
.area-card-shape svg pattern circle {
    fill-opacity: 0.2 !important;
}

/* Legacy support just in case, or alias detail-grid to bento-grid concepts if needed */
.detail-grid {
   /* Inherit or alias to bento grid styles? 
      For now, we will replace usage in PHP. 
      But keeping basic block style here to not break other things if any. */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin: 1rem 0 2rem 0;
}

/* Responsive adjustments */
@media (min-width: 600px) {
    .site-header {
        padding-top: 1.25rem;
    }

    .country-indicator {
        margin-bottom: 0;
        margin-left: auto; /* Push it to the right */
        margin-right: 1rem;
    }

    .main-nav ul {
        flex-wrap: nowrap;
    }

    ul.item-list {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}
/* Breadcrumb Styles */
.header-breadcrumbs {
    /* Adjusted from absolute to allow flex flow or relative positioning */
    position: relative; 
    margin-top: 0.5rem;
    padding-left: 0.5rem;
    z-index: 10;
}

/* Ensure breadcrumbs don't overlap search in hero mode */
.has-hero .header-breadcrumbs {
    position: relative;
    top: auto;
    right: auto;
    width: 100%;
    margin-top: 0.1rem;
    margin-bottom: 0.1rem; /* Compact bottom margin */
    padding: 0 1.5rem;
    justify-content: flex-start; /* Left align under title */
}

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9em;
    justify-content: flex-start; /* Default left align */
}

.has-hero .breadcrumb {
    justify-content: flex-start; /* Left align in hero */
}

.breadcrumb li {
    display: flex;
    align-items: center;
}

.breadcrumb li:not(:last-child)::after {
    content: "›";
    margin: 0 0.2rem; /* Compact spacing */
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2em;
    line-height: 1;
}

.breadcrumb li a {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
}

.breadcrumb li a:hover {
    text-decoration: underline;
}

.breadcrumb li.active span {
    color: rgba(255, 255, 255, 0.78);
    font-weight: normal;
}

/* --- Inline styles moved from PHP files --- */
.geo-header { 
    margin-bottom: 2rem; 
    border-bottom: 1px solid #eee; 
    padding-bottom: 1rem; 
    position: relative; /* For absolute bg shape */
    overflow: hidden; /* Clip the shape */
}
.subtitle { color: #666; font-size: 1.1em; }
.card { background: #fff; padding: 1.5rem; border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); position: relative; overflow: hidden; }
.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li { margin-bottom: 0.5rem; border-bottom: 1px dashed #eee; padding-bottom: 0.25rem; }
.info-list li:last-child { border-bottom: none; }
.section { margin-top: 2rem; }
.tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag { background: #e9ecef; padding: 0.25rem 0.75rem; border-radius: 15px; font-size: 0.9em; color: #495057; }

/* Header Shape Background */
.header-bg-shape {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.5; /* Increased for visibility */
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.header-bg-shape svg {
    height: 100%; 
    width: 100%;
    fill: #e9ecef; /* Use a specific light gray color instead of var */
}

/* Small badge SVG for deepest available ADM boundary */
.header-adm-shape {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: min(320px, 45%);
    z-index: 2;
    pointer-events: none;
}
.header-adm-shape svg {
    width: 100%;
    height: auto;
}
/* Ensure text stays on top */
.geo-header h1, .geo-header .country-flag, .geo-header .subtitle, .geo-header .english-subtitle {
    position: relative;
    z-index: 1;
}

/* Alternate names styling */
.alt-names-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); 
    gap: 0.5rem; 
    font-size: 0.9em; 
}
.alt-name { 
    background: #f8f9fa; 
    padding: 0.25rem 0.5rem; 
    border-radius: 4px; 
    display: flex; /* Use flexbox for vertical alignment */
    flex-direction: column; /* Stack elements vertically */
    align-items: flex-start; /* Align to the start */
    justify-content: center; /* Center content vertically */
    min-height: 2.5em; /* Ensure some minimum height */
} 
.alt-name .name-val {
    font-weight: bold;
    line-height: 1.2; /* Adjust line height for better spacing */
}
.alt-name .lang-codes-group {
    display: block; /* Ensure it takes its own line */
    font-size: 0.7em; /* Smaller font for the group */
    color: var(--light-gray); /* Grey color */
    margin-bottom: 0.2em; /* Small space below languages */
    line-height: 1; /* Tighter line height for codes */
}
.alt-name .lang-code-item {
    display: inline-block; /* Display each language code inline */
    margin-right: 0.3em; /* Space between individual codes */
    text-transform: uppercase; /* Ensure codes are uppercase */
}
.alt-name .lang-code-item:last-child {
    margin-right: 0;
}

/* Meta and Badge styles for places/subregions lists */
.meta { 
    display: flex; 
    gap: 1rem; 
    align-items: center; 
    font-size: 0.85em; 
    color: #666; 
    margin-left: 0.5rem; 
    display: inline-flex; /* Keep it inline with the link if space allows */
} 
.badge { 
    background: #e2e6ea; 
    padding: 0.1rem 0.4rem; 
    border-radius: 4px; 
    color: inherit;
    text-decoration: none;
    display: inline-block;
}
.badge--match {
    background: #ffe08a;
    color: #1a1a1a;
}
.badge--similar {
    background: #fff3cd;
    color: #1a1a1a;
}

.mini-map-wrapper {
    display: grid;
    gap: 0.6rem;
}
.mini-map-section {
    margin: 1rem 0 1.25rem 0;
}
.mini-map-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
}
.mini-map-list {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.55rem;
    background: #fff;
    flex: 1;
    min-height: 0;
    overflow: auto;
}
.mini-map-ad {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.2rem;
    background: #fff;
    overflow: hidden;
    height: 200px;
}
.mini-map-list-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.mini-map-list-sub {
    color: #666;
    font-weight: normal;
    margin-left: 0.25rem;
    font-size: 0.9em;
}
.mini-map-list-items {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.6rem;
}
.mini-map-tags-table td.v {
    color: #111;
    word-break: break-word;
}
.mini-map {
    width: 100%;
    height: 600px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #f1f3f5;
}
.mini-map-sidebar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    height: 100%;
    max-height: 600px;
}
.mini-map-status {
    font-size: 0.9em;
    color: #666;
}
.mini-map-legend {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

@media (min-width: 900px) {
    .mini-map-grid {
        grid-template-columns: 1.4fr 1fr;
    }
}

/* Breadcrumb Type Label */
.crumb-type {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85em;
    margin-left: 0.2rem;
    font-weight: normal;
    display: none; /* Hidden by default */
}

/* Show type label when hovering parent list item */
.breadcrumb li:hover .crumb-type {
    display: inline;
}

/* Alpine JS Cloak */
[x-cloak] { display: none !important; }

/* Internal Nav (TOC) */
.internal-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    padding: 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}
.internal-nav li a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #f1f3f5;
    border-radius: 20px;
    font-size: 0.9em;
    color: var(--text-color);
    transition: background 0.2s;
}
.internal-nav li a:hover {
    background: #e9ecef;
    text-decoration: none;
}

/* Accordion Styles */
.accordion-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
    background: #fff;
}

.accordion-header {
    margin: 0; /* Override default H2/H3 margin */
    padding: 1rem;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1em;
    user-select: none;
}
.accordion-header:hover {
    background: #f1f3f5;
}
.accordion-content {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}
/* Ensure lists inside accordion look good */
.accordion-content .section {
    margin-top: 0; /* Remove top margin of .section inside accordion */
}
.accordion-content h3 {
    display: none; /* Hide original H3 inside as it is now the header */
}

/* English Subtitle */
.english-subtitle {
    font-size: 1.2rem;
    color: var(--light-gray);
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    font-weight: normal;
}

/* Flag styling */
.country-flag {
    margin: 0.5rem 0 1rem 0;
}
.country-flag img {
    height: 32px;
    width: auto;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    border-radius: 2px;
    vertical-align: middle;
}

.icon-inline {
    width: 1.1em;
    height: 1.1em;
    vertical-align: text-bottom;
    margin-right: 0.35em;
    display: inline-block;
    color: var(--primary-color);
    opacity: 0.85;
}

.info-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.info-list li strong {
    display: inline-flex; /* Align icon and text inline */
    align-items: center;
    margin-bottom: 0;
    margin-right: 0.5rem;
}

/* Specific styling for continent capital label */
.continent-capital-label {
    font-size: 0.75em; /* Smaller font size */
    color: var(--light-gray);
    display: inline-flex;
    align-items: center;
    margin-left: 0.5rem; /* Add some spacing */
}

.continent-capital-label .icon-inline {
    width: 0.9em; /* Smaller icon */
    height: 0.9em;
    opacity: 0.6;
    margin-right: 0.2em;
}

/* --- Consolidated Hero Header Styles --- */
.header-surface.has-hero {
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Left align items */
    justify-content: flex-start; /* Use gap and margins for spacing */
    text-align: left;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    gap: 1.2rem; /* Reduced from 1.5rem */
    
    padding-bottom: 0.5rem; /* Compact bottom padding */
    min-height: 117px; /* Reduced by 10% */
    
    overflow: visible; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-hero-content {
    /* position: relative; removed to allow children to anchor to header-surface */
    z-index: 5;
    width: 100%;
    max-width: 100%; 
    flex-grow: 1; /* Fill available space */
    color: #fff;
    display: flex;
    flex-direction: column; 
    padding-right: 0; /* Default (mobile): no right padding */
}

.hero-search-wrapper {
    position: relative; 
    margin: 0.5rem 0 0 0.5rem; /* Slightly reduced top margin since gap increased */
    z-index: 6; /* Ensure it's above other elements */
    width: 100%; /* Fill available width */
    max-width: 400px; /* Limit width like index.php */
    height: auto; /* Let content dictate height */
}

.hero-search-input {
    width: 100%;
    height: auto; /* Fill wrapper */
    border-radius: 50px; /* index.php style */
    border: none;
    padding: 1rem 1.5rem; /* index.php style */
    font-size: 1.5rem; /* index.php style */
    color: #333;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20viewBox%3D%270%200%2024%2024%27%20fill%3D%27none%27%20stroke%3D%27%23333%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Ccircle%20cx%3D%2711%27%20cy%3D%2711%27%20r%3D%277%27/%3E%3Cline%20x1%3D%2721%27%20y1%3D%2721%27%20x2%3D%2716.65%27%20y2%3D%2716.65%27/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 24px center; /* Adjusted position */
    background-size: 24px; /* Larger icon */
    transition: all 0.3s ease;
}

.hero-text-wrapper {
    position: relative;
    margin-top: 0.5rem; /* Ensure some space above if stacked closely */
    margin-left: -2.5rem; /* Banner effect: stick out left */
    margin-bottom: 0.5rem;
    text-align: left;
    z-index: 6;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 30px 10px 75px; /* Ample room for the flag */
    border-radius: 12px 40px 40px 12px; /* Slightly rounded left corners */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 64px;
    width: fit-content;
    max-width: 100%;
    align-self: flex-start;
}

/* Flag inside text wrapper (new layout) */
.hero-text-wrapper .header-flag-overlap {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    bottom: auto; /* Override specific positioning */
    margin: 0;
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 50%;
    padding: 3px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hero-text-wrapper .header-flag-overlap img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(0,0,0,0.05);
}

.header-hero-title {
    margin-left: 0; 
    font-size: 1.5rem;
    font-weight: 800;
    margin-top: 0;
    margin-bottom: 0.1rem;
    line-height: 1.1;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.header-hero-subtitle {
    margin-left: 0; 
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 0;
    margin-top: 0;
    font-weight: 400;
    transition: all 0.3s ease;
}

.header-flag-overlap {
    position: absolute;
    bottom: 23px; /* Adjusted to center vertically with the text block */
    left: 15px; /* Precisely at the start of the title background */
    transform: none; 
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 50%;
    padding: 3px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}
.header-flag-overlap img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover; /* Reverted to cover as requested */
    border: 1px solid rgba(0,0,0,0.05);
}

/* --- Scrolled / Shrinking Header State --- */
.header-scrolled .header-surface.has-hero {
    min-height: 80px;
    padding-bottom: 1rem;
    padding-top: 0.5rem;
}

.header-scrolled .hero-search-wrapper {
    margin-top: 0.5rem;
    margin-left: 0.5rem;
    width: 250px; /* Slightly smaller width in scrolled state */
    height: 40px; /* Smaller height in scrolled state */
}
.header-scrolled .hero-search-input {
    font-size: 0.9rem; /* Smaller font in scrolled state */
    background-size: 18px; /* Smaller icon in scrolled state */
    padding: 0 45px 0 20px; /* Adjust padding for smaller size */
    border-radius: 20px; /* Half of height for perfect roundness */
}

.header-scrolled .hero-text-wrapper {
    margin-bottom: 0.5rem;
    padding: 6px 25px 6px 60px;
    border-radius: 8px 30px 30px 8px; /* Maintain slight rounding when small */
}

.header-scrolled .header-hero-title {
    font-size: 1.2rem;
    margin-left: 0; 
}
.header-scrolled .header-hero-subtitle {
    display: none; 
}

.header-scrolled .header-flag-overlap {
    width: 36px;
    height: 36px;
    bottom: 12px;
    left: 10px;
}
/* Scrolled state for nested flag */
.header-scrolled .hero-text-wrapper .header-flag-overlap {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    left: 10px;
}

.header-scrolled .hero-globe-wrapper {
    opacity: 0; 
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
}


.hero-globe-wrapper {
    position: absolute;
    right: -0.5rem; /* Globe more to the right */
    bottom: 5px; 
    top: auto;
    transform: none;
    height: 80px; /* Adjusted for mobile */
    width: 80px;
    z-index: 12; 
    pointer-events: auto; /* Allow hover */
    display: block; 
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}
/* Globe Hover Effect */
.hero-globe-wrapper:hover {
    transform: scale(1.5) rotate(-2deg);
    z-index: 20;
}

/* Added missing image styles for the globe */
.hero-globe-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 12px 24px rgba(0,0,0,0.3));
    animation: floatGlobe 8s ease-in-out infinite;
}

@keyframes floatGlobe {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@media (min-width: 768px) {
    .hero-globe-wrapper {
        display: block;
        height: 140px; /* Reduced */
        width: 140px;
        right: -0.5rem; 
        bottom: -30px;
    }
    
    .header-surface.has-hero {
        padding-bottom: 0.6rem; /* Compact bottom padding */
        min-height: 158px; /* Reduced by ~10% */
    }
    
    /* Scrolled state desktop */
    .header-scrolled .hero-globe-wrapper {
        opacity: 0.2; 
        transform: scale(0.6) translateY(10px);
        pointer-events: none;
    }
}

@media (min-width: 992px) {
    .hero-globe-wrapper {
        height: 180px; /* Reduced */
        width: 180px;
        right: 0.5rem; 
        bottom: -40px;
    }
    
    .header-hero-content {
        padding-right: 180px; 
    }

    .hero-search-wrapper {
        max-width: 400px; 
        margin: 0 0 0.5rem 0; 
        align-self: flex-start;
    }
}

.country-list-flag {
    width: 26px; 
    height: auto;
    vertical-align: middle;
    margin-right: 10px;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-radius: 4px;
    transition: transform 0.2s ease;
}

.country-list-flag:hover {
    transform: scale(1.1);
}

.text-muted {
    color: #6c757d;
    font-size: 0.85em;
}

/* Global Search (Top Center) */
.global-search-wrapper {
    position: absolute;
    top: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    width: auto;
}
.global-search-input {
    height: 36px;
    width: 200px;
    padding: 0 36px 0 12px;
    border-radius: 18px;
    border: 1px solid rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.9);
    font-size: 0.9rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    transition: all 0.2s ease;
}
.global-search-input:focus {
    background: #fff;
    width: 240px;
    outline: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Position search over the globe when hero is present */
.header-surface.has-hero .global-search-wrapper {
    left: auto;
    right: 0;
    transform: none;
    top: 1rem; /* Mobile: Anchor to top */
    bottom: auto; 
    display: flex;
    justify-content: flex-end;
    padding-right: 1rem;
    z-index: 25; /* Ensure above globe (z-index 12-20) */
}

/* Stronger shadow for search over globe */
.header-surface.has-hero .global-search-input {
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.1);
    border-color: rgba(255,255,255,0.4);
}

/* Scrolled state: Dock search back to header */
.header-scrolled .header-surface.has-hero .global-search-wrapper {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    right: 1rem;
    padding-right: 0;
}

/* Reset shadow in scrolled state */
.header-scrolled .header-surface.has-hero .global-search-input {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

@media (min-width: 768px) {
    .header-surface.has-hero .global-search-wrapper {
        bottom: 80px; /* Tablet: Moved down 20px */
        right: 0; 
        padding-right: 0.5rem;
    }
}

@media (min-width: 992px) {
    .header-surface.has-hero .global-search-wrapper {
        bottom: 110px; /* Desktop: Moved down 20px */
        right: 1rem;
        padding-right: 0;
    }
}

/* Footer Search */
.footer-search input::placeholder {
    color: rgba(255,255,255,0.7);
}
.footer-search input:focus {
    background: rgba(255,255,255,0.2) !important;
    outline: none;
    border-color: rgba(255,255,255,0.4) !important;
}

@media (max-width: 600px) {
    .global-search-wrapper {
        top: 0.8rem;
        /* Keep centered on mobile too */
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
    .global-search-input {
        width: 160px; /* Slightly wider on mobile for better usability */
        font-size: 0.8rem;
    }
    .global-search-input:focus {
        width: 200px;
    }
}
