html,
body {
    font-size: 18px;
    font-family: 'Lora', serif;
    margin: 0;
    display: flex;
    height: 100%;
    width: 100%;
    flex-direction: row;
    overflow: hidden;
    background-color: #6c695e;
}

#main-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

#mapContainer {
    position: relative;
}

/* Floating info panel (top-right) */
.info-panel {
    position: fixed;
    top: 12px;
    right: 12px;
    width: clamp(220px, 22vw, 320px);
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid #9a8770;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    padding: 10px 12px;
    z-index: 1001;
}

.info-panel h2 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1.15em;
    line-height: 1.2;
}

.info-panel h3 {
    margin: 10px 0 6px 0;
    color: #333;
    font-size: 1em;
    line-height: 1.2;
}

.info-panel p,
.info-panel li {
    color: #444;
    line-height: 1.45;
    font-size: 13px;
}

.info-panel ul {
    padding-left: 16px;
    margin: 4px 0 8px 0;
}

/* Zoom controls (bottom-left) */
.zoom-controls {
    position: fixed;
    left: calc(clamp(240px, 28vw, 420px) + 60px);
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10001;
    transition: left 0.3s ease;
}

/* When sidebar is hidden, move zoom buttons to the left */
#legend[style*="display: none"] ~ #mapContainer .zoom-controls,
body.sidebar-hidden .zoom-controls {
    left: 24px;
}

.zoom-controls button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #8a7456;
    background: #a89378;
    color: white;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.zoom-controls button:hover {
    background: #8a7456;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.zoom-controls button:active {
    transform: scale(0.96);
}

/* =========================================================================== */
/* SIDEBAR & LEGEND STYLING                                                  */
/* =========================================================================== */

#legend {
    position: fixed;
    left: 12px;
    top: 12px;
    bottom: 12px;
    width: clamp(240px, 28vw, 420px);
    min-width: 220px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid #9a8770;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

#legend-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 0px;
    padding-bottom: 8px;
    border-bottom: 2px solid #a89378;
}

.title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.sidebar-title h1 {
    font-size: 1.6em;
    margin: 0;
    color: #333;
    font-weight: bold;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.sidebar-desc {
    font-size: 1em;
    color: #555;
    margin: 0 0 0.5em 0;
    line-height: 1.4;
}

#tab-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

#tab-buttons {
    display: flex;
    gap: 4px;
    flex: 1;
}

.tab-btn {
    flex: 1;
    background: #e0e0e0;
    color: #333;
    border: 2px solid #999;
    padding: 8px 12px;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: #d0d0d0;
}

.tab-btn.active {
    background: #a89378;
    color: white;
    border-color: #9a8770;
}

.tab-content {
    display: none;
    overflow-y: auto;
    flex: 1;
    animation: fadeIn 0.2s ease;
}

.tab-content.active {
    display: block;
}

#legend-content {
    overflow-y: auto;
    margin-top: 4px;
    display: flex;
    justify-content: center;
    flex: 1;
}

/* =========================================================================== */
/* DATA TABS (Countries & Wine Regions)                                       */
/* =========================================================================== */

#data-tabs-container {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #a89378;
}

#data-tab-buttons {
    display: flex;
    gap: 4px;
    margin-bottom: 0;
    border-bottom: 2px solid #a89378;
}

.data-tab-btn {
    flex: 1;
    background: #e0e0e0;
    color: #333;
    border: 2px solid #999;
    border-bottom: none;
    padding: 10px 12px;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Lora', serif;
    transition: all 0.2s ease;
}

.data-tab-btn:hover {
    background: #d0d0d0;
}

.data-tab-btn.active {
    background: #f9f9f9;
    color: #333;
    border-color: #a89378;
    border-bottom: 2px solid #f9f9f9;
    position: relative;
    z-index: 2;
}

.data-tab-content {
    display: none;
    padding: 15px;
    background: #f9f9f9;
    border: 2px solid #a89378;
    border-top: none;
    border-radius: 0 0 6px 6px;
    margin-top: -2px;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.data-tab-content.active {
    display: block;
}

/* Legend content */
.legend-section {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 9px 12px;
    margin: 4px 0 0;
    width: 100%;
}

.legend-section h2 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
}

.legend-item:last-child {
    border-bottom: none;
}

.legend-swatch {
    width: 24px;
    height: 24px;
    display: inline-block;
    flex: 0 0 24px;
    margin-top: 2px;
}

.legend-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 15px;
    color: #444;
}

.legend-text strong {
    font-size: 15px;
    color: #333;
}

.legend-distillery {
    width: 35px;
    height: 35px;
    flex: 0 0 35px;
    background: url('symbol/slice5.svg') center/contain no-repeat;
}

.legend-port {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    background: url('symbol/slice4.svg') center/contain no-repeat;
}

.legend-route {
    width: 22px;
    height: 6px;
    margin-top: 8px;
    background: #922029;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}

.legend-country {
    background: #ada096;
    border: 1px solid #999;
    border-radius: 3px;
}

#tab-controls-content {
    display: block !important;
    flex: 0 0 auto;
    margin-bottom: 8px;
}

#wine-region-control {
    margin-top: 15px;
    padding: 10px;
    border-radius: 6px;
}

#wine-region-control label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

#wine-region-dropdown {
    width: 100%;
    padding: 8px;
    border: 2px solid #999;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Lora', serif;
}

#wine-region-dropdown:focus {
    outline: none;
    border-color: #9a8770;
    box-shadow: 0 0 0 2px rgba(168, 147, 120, 0.1);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#sidebar-toggle {
    background: #a89378;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: opacity 0.2s;
}

#sidebar-toggle:hover {
    opacity: 0.9;
}

.sidebar-show-button,
#sidebar-show {
    position: fixed;
    left: 10px;
    top: 10px;
    z-index: 9999;
    background: #a89378;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: opacity 0.2s;
}

.sidebar-show-button:hover {
    opacity: 0.9;
}



/* =========================================================================== */
/* MAP CONTAINER & VISUALIZATION                                             */
/* =========================================================================== */

#mapContainer {
    flex: 1;
    position: relative;
    height: 100%;
    width: 100%;
    background: url('symbol/wooden-floor-background.jpg') center/cover no-repeat;
    overflow: hidden;
}

#mapContainer svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* =========================================================================== */
/* MAP LAYER STYLES                                                           */
/* =========================================================================== */

.graticule {
    fill: none;
    stroke: #fff;
    stroke-width: 0.5px;
    stroke-opacity: 0.3;
}

.country {
    fill: #ada096;
    fill-opacity: 0.5;
    stroke: #574c3b;
    stroke-width: 1px;
}

.country:hover {
    fill: #7d3518;
    fill-opacity: 0.5;
    stroke: #fff;
    stroke-width: 1px;
    cursor: pointer;
}

/* Subtle highlight for countries that have shipping/trade data */
.country.has-data {
    fill: #8f8072;
    stroke: #574c3b;
    stroke-width: 1px;
    fill-opacity: 0.5;
}

.country.has-data:hover {
    stroke: #fff;
    stroke-width: 1px;
}

/* Hover outline drawn above all layers */
.country-hover-outline {
    fill: none;
    stroke: #ffffff;
    stroke-width: 1.5px;
    stroke-linejoin: round;
    pointer-events: none;
}

.lake {
    fill: none;
    stroke: #7ea6c8;
    stroke-width: 0.2px;
    stroke-opacity: 0.55;
}

.river {
    fill: none;
    stroke: #124c7f;
    stroke-width: 0.25px;
    stroke-opacity: 0.65;
}

.coastline {
    fill: none;
    stroke: #8a8a8a;
    stroke-width: 0.5px;
}

/* =========================================================================== */
/* SHIPPING ROUTES & INTERACTIONS                                             */
/* =========================================================================== */

.shipping-route:hover {
    stroke-width: 6px !important;
    stroke: #d17373 !important;
    cursor: pointer;
    filter: drop-shadow(0 0 5px #fff);
}

.tooltip {
    position: absolute;
    text-align: left;
    padding: 10px;
    font-family: 'Lora', serif;
    font-size: 12px;
    background: #a89378;
    color: #fff;
    border: 2px solid #8a7456;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    box-shadow: 0 0 0 3px #a89378, 0 0 0 5px #6d5a42, 2px 2px 6px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.tooltip strong,
.tooltip span {
    color: #fff !important;
}

/* =========================================================================== */
/* COUNTRY SELECTION UI                                                       */
/* =========================================================================== */

.country-items-container {
    display: none;
    overflow-y: auto;
    flex: 1;
    margin-top: 8px;
    padding-right: 4px;
}

.country-items-container::-webkit-scrollbar {
    width: 6px;
}

.country-items-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.country-items-container::-webkit-scrollbar-thumb {
    background: #a89378;
    border-radius: 3px;
}

.country-items-container::-webkit-scrollbar-thumb:hover {
    background: #8a7456;
}

.country-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    font-size: 13px;
    color: #222;
    border-radius: 4px;
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.country-item:hover {
    background: rgba(168, 147, 120, 0.08);
}

.country-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #a89378;
}

.country-label {
    flex: 1;
    cursor: pointer;
    user-select: none;
}

.country-search {
    font-family: 'Segoe UI', sans-serif;
    transition: border-color 0.2s ease;
}

.country-search:focus {
    outline: none;
    border-color: #9a8770 !important;
    box-shadow: 0 0 0 2px rgba(168, 147, 120, 0.1);
}

.country-btn {
    display: none;
    flex: 1;
    background: #a89378;
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.country-btn:hover {
    background: #8a7456;
}

.country-btn:active {
    transform: scale(0.98);
}
/* =========================================================================== */
/* HELP BUTTON & MODAL STYLING                                               */
/* =========================================================================== */

.help-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #a89378;
    color: white;
    border: 2px solid #8a7456;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.help-button:hover {
    background: #8a7456;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.help-button:active {
    transform: scale(0.95);
}

/* Modal Overlay */
.modal {
    display: none;
    position: fixed;
    /* Ensure the help modal overlays all UI panels (cask stats, zoom buttons, etc.) */
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modal Content Box */
.modal-content {
    background-color: #f9f9f9;
    padding: 30px;
    border: 2px solid #9a8770;
    border-radius: 8px;
    width: min(90vw, 640px);
    max-height: min(80vh, 720px);
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover,
.close:focus {
    color: #000;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5em;
}

.modal-content p {
    margin: 10px 0;
    line-height: 1.6;
    color: #555;
    font-size: 14px;
}

.modal-content strong {
    color: #9a8770;
}

/* Ensure ocean sphere has no outline ring */
.sphere {
    stroke: none;
}

/* Wooden background layer - add stroke for globe edge */
.wooden-background {
    stroke: #574c3b;
    stroke-width: 2px;
}

/* Cask statistics panel sizing */
#cask-stats-panel {
    width: clamp(220px, 24vw, 360px);
}