/* World Tracker: "Travel log" design */

:root {
    --page: #eef1eb;          /* map background */
    --card: #ffffff;
    --ink: #1c2a22;
    --muted: #4e5c53;         /* 6.6:1 on white */
    --line: #e3e7e1;
    --control: #b6c0b8;       /* button and input borders */

    --land: #ffffff;
    --border: #8e978f;
    --other-land: #f3f4ef;    /* areas outside the country catalog */
    --other-border: #b7bdb6;
    --visited: #2e7d4f;
    --visited-dark: #1f5a38;
    --visited-hover: #48996a;
    --unvisited-hover: #dcebe0;

    --tag: #e3f1e7;
    --tag-old: #eef1ec;

    --sans: "Albert Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

    color-scheme: light;
}

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

html,
body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--page);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

h1,
p {
    margin: 0;
}

button,
input {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--visited-dark);
    outline-offset: 2px;
}

[x-cloak] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- Layout: map on the left, panel on the right ---------- */

.app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    height: 100vh;
    height: 100dvh;
}

/* ---------- Map ---------- */

.map-area {
    position: relative;
    overflow: hidden;
    touch-action: none;       /* the map handles drag and pinch itself */
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
}

.map-area.is-dragging {
    cursor: grabbing;
}

.map-area:focus-visible {
    outline-offset: -4px;
}

.map {
    display: block;
    width: 100%;
    height: 100%;
}

.country,
.land {
    vector-effect: non-scaling-stroke;   /* borders stay thin when zoomed in */
    stroke-linejoin: round;
}

.land {
    fill: var(--other-land);
    stroke: var(--other-border);
    stroke-width: 0.5;
}

.country {
    fill: var(--land);
    stroke: var(--border);
    stroke-width: 0.6;
    transition: fill 100ms ease;
}

.country.is-visited {
    fill: var(--visited);
    stroke: var(--visited-dark);
}

.country.is-home {
    fill: url(#home-hatch);
    stroke: var(--visited-dark);
}

.country.is-hovered {
    fill: var(--unvisited-hover);
    stroke: var(--visited-dark);
    stroke-width: 1.4;
}

.country.is-visited.is-hovered {
    fill: var(--visited-hover);
}

.country.is-home.is-hovered {
    fill: url(#home-hatch);
    stroke-width: 2;
}

.map-hint {
    position: absolute;
    left: 28px;
    top: 24px;
    font-size: 14px;
    color: var(--muted);
    pointer-events: none;
}

.hint-touch {
    display: none;
}

@media (hover: none) {
    .hint-mouse {
        display: none;
    }

    .hint-touch {
        display: inline;
    }
}

.tooltip {
    position: absolute;
    z-index: 2;
    display: flex;
    gap: 10px;
    padding: 9px 13px;
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
}

.tooltip[hidden] {
    display: none;
}

.tooltip__name {
    font-weight: 700;
}

.tooltip__detail {
    color: #c4d2c9;
}

.tooltip__detail:empty {
    display: none;
}

.map-controls {
    position: absolute;
    right: 24px;
    bottom: 24px;
    display: flex;
    gap: 6px;
}

.map-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--control);
    border-radius: 8px;
    background: var(--card);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.map-btn:hover {
    background: #f5f7f4;
}

.map-btn--text {
    width: auto;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 600;
}

.map-btn[hidden] {
    display: none;
}

/* ---------- Panel ---------- */

.panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-top: 30px;
    background: var(--card);
    border-left: 1px solid #d5dad2;
}

.panel__intro {
    padding: 0 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.count {
    color: var(--muted);
}

.count__number {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.legend {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 13px;
    color: var(--muted);
}

.legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.swatch--visited {
    background: var(--visited);
}

.swatch--home {
    border: 1px solid var(--visited-dark);
    background: repeating-linear-gradient(45deg, var(--visited) 0 2px, #fff 2px 4px);
}

.swatch--none {
    border: 1px solid var(--border);
}

.search {
    position: relative;
    margin-top: 4px;
    color: var(--muted);
}

.search svg {
    position: absolute;
    left: 13px;
    top: 14px;
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 44px;
    padding: 0 12px 0 38px;
    border: 1px solid var(--control);
    border-radius: 8px;
    background: var(--card);
    color: var(--ink);
    font-size: 15px;
}

.search input:focus-visible {
    border-color: var(--visited-dark);
    outline-offset: 0;
}

.list-head {
    margin-top: 14px;
    padding: 0 28px 8px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

.visit-list {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 4px 0;
    list-style: none;
    overflow-y: auto;
}

.visit {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 28px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.visit:hover,
.visit.is-hovered {
    background: #eaf3ec;
}

.visit.is-hovered .visit__name {
    font-weight: 600;
}

.visit:focus-visible {
    outline-offset: -2px;
}

.visit__name {
    padding-top: 1px;
}

.visit__years {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    max-width: 216px;
}

.tag {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--tag-old);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tag--latest {
    background: var(--tag);
    color: var(--visited-dark);
    font-weight: 700;
}

.no-match {
    padding: 16px 28px;
    color: var(--muted);
}

.panel__note {
    padding: 14px 28px 18px;
    border-top: 1px solid var(--line);
    font-size: 13px;
    color: var(--muted);
}

/* ---------- Small screens: map on top, list below ---------- */

@media (max-width: 900px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto;
        height: auto;
    }

    /* Roughly the map's own shape, so a narrow screen isn't mostly empty space */
    .map-area {
        height: clamp(280px, 70vw, 60vh);
    }

    .panel {
        border-left: none;
        border-top: 1px solid #d5dad2;
        padding-top: 24px;
    }

    .panel__intro,
    .list-head,
    .visit,
    .no-match,
    .panel__note {
        padding-left: 20px;
        padding-right: 20px;
    }

    .visit-list {
        overflow: visible;   /* the page scrolls instead */
    }

    .map-hint {
        left: 16px;
        top: 14px;
        font-size: 13px;
    }

    .map-controls {
        right: 16px;
        bottom: 16px;
    }
}