/* -----------------------------------------------------------
   ROOT VARIABLES & BASE STYLES
----------------------------------------------------------- */
:root {
    --filter-bar-height: 66px;
    --tag-row-height: 48px;
    --sub-tag-row-height: 36px;
    --sub-row-gap: 4px;
}

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

body {
    display: flex;
    flex-direction: column;
    background-color: var(--primary);
    font-family: var(--global-font);
    overflow-x: hidden;
    scrollbar-width: none;
}

body::-webkit-scrollbar {
    display: none;
}

a,
a:link,
a:visited {
    color: var(--accent);
    text-decoration: none;
}

a:active {
    color: var(--accent);
    text-decoration: underline;
}

/* Hover styling only where a real pointer exists — on a touchscreen a tap
   applies :hover and it sticks until you tap something else, leaving buttons
   and bubbles looking permanently selected. */
@media (hover: hover) {
    a:hover {
        color: var(--accent);
        text-decoration: underline;
    }
}

select option {
    font-weight: 900;
}

/* -----------------------------------------------------------
   BUTTON & SELECT RESETS
----------------------------------------------------------- */
button,
select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: none;
    border: 1px solid var(--secondary_grey);
    outline: none;
    padding: 4px 12px;
    font-family: inherit;
    font-size: 12px;
    color: var(--secondary);
    border-radius: 16px;
    background-color: var(--secondary_grey);
    transition:
        background-color 0.2s,
        color 0.2s;
    cursor: pointer;
}

@media (hover: hover) {
    button:hover,
    select:hover {
        border-color: var(--accent);
        border: 1px solid var(--accent);
        color: var(--secondary);
    }
}

button:active,
select:active {
    border: 1px solid var(--accent);
    border-color: var(--accent);
}

button:disabled,
select:disabled {
    background-color: var(--primary_grey);
    color: var(--secondary_grey);
    cursor: not-allowed;
}

/* -----------------------------------------------------------
   TOP BAR & FILTER BAR
----------------------------------------------------------- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    transition:
        transform 0.3s ease,
        opacity 0.3s ease;
    will-change: transform, opacity;
    border-radius: 0 0 16px 16px;
}

.top-bar.hidden {
    transform: translateY(-100%);
    opacity: 0;
}

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 10px 0 10px 10px;
    background-color: var(--primary);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    flex: 1;
    min-width: 0;
    transition:
        background-color 0.1s ease,
        border-radius 0.1s ease;
}

.filter-bar.hidden {
    transform: translateY(-100%);
    opacity: 0;
}

.filter-bar.scrolled {
    background-color: transparent;
    border-radius: 60px;
    transition:
        background-color 0.1s linear 0.1s,
        border-radius 0.1s linear 0.1s;
}

.filter-left,
.filter-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* -----------------------------------------------------------
   TOP BAR BRANDING & MENU
----------------------------------------------------------- */
.menu-bar {
    height: 50px;
    max-width: 35vw;
    border-radius: 16px;
    background: var(--primary);
    display: flex;
    align-items: center;
    overflow: visible;
    border: 1px solid var(--primary);
    transition: border-color 0.2s;
}

.menu-bar.custom-dropdown {
    width: auto;
    height: 50px;
}

#menuFavicon {
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 16px 0 0 16px;
}

#menuTitle {
    flex: 1 1 auto;
    padding: 0 10px;
    white-space: normal;
    overflow-wrap: break-word;
    color: var(--secondary_grey);
    font-size: clamp(12px, 3vw, 16px);
}
#menuMainTitle,
#menuMainTitleClone {
    max-height: 40px;
    max-width: 100%; /* Add this line */
    width: auto;
    object-fit: contain;
    transition: max-height 0.2s ease-in-out;
}
#menuMainTitle {
    max-height: 80px;
}

/* Icon badge + site name (script.js updateMainMenuIcon) in one box the same
   height, border and corners as the search box beside it, so the two read as
   one split bar. The bar itself stays 50px tall: the rows below are placed
   for that height. */
.menu-bar.has-badge {
    display: flex; /* .custom-dropdown (later) makes it inline-block, which left the box at the top */
    align-items: center;
    background: transparent;
    border-color: transparent;
    max-width: 60vw; /* room for a two-line name in full; search takes the rest */
    flex-shrink: 0;
}
.menu-bar.has-badge .dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    height: 37px;
    box-sizing: border-box;
    padding: 0 10px 0 4px;
    background: var(--primary);
    border: 1px solid var(--primary_grey);
    border-radius: 16px;
}
.menu-bar.has-badge #menuFavicon,
.menu-bar.has-badge #menuFaviconClone {
    flex: 0 0 27px;
    width: 27px;
    height: 27px;
    border-radius: 50%; /* 4px clear of the border all round */
    object-fit: cover;
    background: #fff;
}
/* The name on up to two small lines, like a logo. */
.menu-bar.has-badge #menuFallback,
.menu-bar.has-badge #menuFallbackClone {
    display: -webkit-box !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    min-width: 0;
    max-width: 13em; /* script.js fitNameToLines trims it to the widest line */
    overflow: hidden;
    white-space: normal;
    font-size: 11.5px;
    line-height: 13px;
    font-weight: 700;
    text-align: left;
    color: var(--secondary);
}

#menuFallback,
#menuFallbackClone {
    padding: 0 1px;
    font-weight: 600;
    color: var(--secondary_grey);
    white-space: wrap;
    font-size: clamp(2px, 2.8vw, 16px);
    box-shadow: None;
}

.static-page-header #menuMainTitle {
    max-height: 65px;
}

/* -----------------------------------------------------------
   SEARCH & SUGGESTIONS
----------------------------------------------------------- */
.search-container {
    width: 100%;
    max-width: 100%;
    flex: 1;
    min-width: 0;
    padding-right: 10px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--primary_grey);
    border-radius: 16px;
    background: var(--primary);
    height: 35px;
    padding: 0 10px;
}

.search-box .search-icon {
    color: var(--secondary_grey);
    font-size: 16px;
    margin-right: 6px;
    flex: 0 0 auto;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: var(--primary);
    color: var(--secondary_grey);
    font-size: 16px;
    padding: 10px 5px;
    margin: 0;
    width: 246px;
}

@media (max-width: 768px) {
    .search-box input.compact {
        width: 30px;
    }
}

.suggestion-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--primary);
    border: 1px solid var(--primary_grey);
    border-top: none;
    border-radius: 16px;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
}

.suggestion-box div {
    padding: 10px;
    cursor: pointer;
    z-index: 9999;
    font-size: 16px;
    border-radius: 16px;
}

.suggestion-box .highlighted {
    background: var(--accent);
}

@media (hover: hover) {
    .suggestion-box div:hover {
        background: var(--accent);
    }
}

.suffix {
    font-size: 0.75em;
    font-weight: 650;
    color: var(--primary_grey);
    margin-left: 4px;
}

/* -----------------------------------------------------------
   SEARCH INPUT TAGS
----------------------------------------------------------- */
#searchTagsContainer {
    display: flex;
    align-items: center;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#searchTagsContainer::-webkit-scrollbar {
    display: none;
}

#searchTagsContainer .tag-bubble,
#searchTagsContainer input {
    flex: 0 0 auto;
    white-space: nowrap;
}

#searchTagsContainer input {
    background: transparent;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 4px 6px;
    min-width: 120px;
}

.tag-bubble {
    display: inline-flex;
    align-items: center;
    background-color: #ebebebb3;
    color: var(--secondary_grey);
    border-radius: 16px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    position: relative;
}

@media (hover: hover) {
    .tag-bubble:hover {
        background-color: var(--primary_grey);
    }
}

.tag-bubble.remove-hover {
    background-color: var(--red) !important;
    text-decoration: line-through;
    color: var(--primary) !important;
}

.remove-tag {
    margin-left: 8px;
    font-weight: bold;
    cursor: pointer;
}

/* -----------------------------------------------------------
   TAG & FILTER BUBBLE ROWS
----------------------------------------------------------- */
.tag-bubbles-row {
    position: fixed;
    top: var(--filter-bar-height);
    left: 0;
    right: 0;
    height: var(--tag-row-height);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 10px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    background: var(--primary);
    z-index: 2;
    transition:
        transform 0.3s ease,
        opacity 0.3s ease;
    will-change: transform, opacity;
    box-sizing: border-box;
    /* Windows/Edge uses classic scrollbars that consume height inside this
     fixed-height row, clipping the bubbles. Hide them (macOS overlay
     scrollbars cost no layout) and rely on drag / wheel scrolling. */
    scrollbar-width: none;
    -ms-overflow-style: none;
    overscroll-behavior-x: contain;
}

.tag-bubbles-row::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.tag-bubbles-row.hidden {
    transform: translateY(-100%);
    opacity: 0;
    transition:
        transform 0.3s ease,
        opacity 0.3s ease;
}

.tag-bubbles-row.overflowing {
    justify-content: flex-start;
}

/* Soft edge fades as the "more to see" hint (the scrollbar is hidden). They are
   opaque overlays pinned to the row's edges, not a mask: a mask also faded the
   row's own background, so photos scrolling behind showed through. Each overlay
   runs from the row's outer edge (the -10px margin and inset reach over the 10px
   padding, where sticky would otherwise stop) and its other margin hands back
   its width and the gap less that padding, so the bubbles keep their 10px. */
.tag-bubbles-row.overflowing::before,
.tag-bubbles-row.overflowing::after {
    content: '';
    position: sticky;
    z-index: 1;
    flex: 0 0 28px;
    align-self: stretch;
    pointer-events: none;
    transition: opacity 0.15s;
}

.tag-bubbles-row.overflowing::before {
    left: -10px;
    margin: 0 -24px 0 -10px;
    background: linear-gradient(to right, var(--primary), transparent);
}

.tag-bubbles-row.overflowing::after {
    right: -10px;
    margin: 0 -10px 0 -24px;
    background: linear-gradient(to left, var(--primary), transparent);
}

.tag-bubbles-row.overflowing.at-start::before,
.tag-bubbles-row.overflowing.at-end::after {
    opacity: 0;
}

.tag-bubbles-row .tag-bubble,
.tag-bubbles-row .sort-bubble,
.tag-bubbles-row .trip-bubble {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 16px;
    font-size: 0.9em;
    background-color: #eee;
    cursor: pointer;
    transition:
        background 0.2s,
        color 0.2s;
}

.tag-bubbles-row .trip-bubble {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 1000px;
}

.tag-bubbles-row .sort-separator,
.tag-bubbles-row .divider {
    flex: 0 0 auto;
    width: 1px;
    height: 1.2em;
    background-color: #ccc;
    margin: 0 8px;
}

/* Bubble Colors */
.tag-bubbles-row .sort-bubble {
    background-color: rgba(255, 170, 90, 0.3);
    color: #000;
    border: 1px solid transparent;
}

.tag-bubbles-row .tag-bubble {
    background-color: rgba(186, 217, 181, 0.3);
    color: #000;
    border: 1px solid transparent;
}

.tag-bubbles-row .trip-bubble {
    background-color: rgba(255, 120, 90, 0.3);
    color: #000;
    border: 1px solid transparent;
}

/* Selected & Hover Bubble Colors */
.tag-bubbles-row .sort-bubble.selected {
    background-color: #ffaa5a;
    border-color: #8c6d33;
    color: #000;
}

@media (hover: hover) {
    .tag-bubbles-row .sort-bubble:hover {
        background-color: #ffaa5a;
        border-color: #8c6d33;
        color: #000;
    }
}

.tag-bubbles-row .tag-bubble.selected {
    background-color: #bad9b5;
    border-color: #6b8c5e;
    color: #000;
}

@media (hover: hover) {
    .tag-bubbles-row .tag-bubble:hover {
        background-color: #bad9b5;
        border-color: #6b8c5e;
        color: #000;
    }
}

.tag-bubbles-row .trip-bubble.selected {
    background-color: #ff785a;
    border-color: #8c4333;
    color: #000;
}

@media (hover: hover) {
    .tag-bubbles-row .trip-bubble:hover {
        background-color: #ff785a;
        border-color: #8c4333;
        color: #000;
    }
}

/* Sub-row Styling */
#subTagBubblesRow,
#tripSubRow {
    top: calc(var(--filter-bar-height) + var(--tag-row-height) + var(--sub-row-gap) - 4px);
    z-index: 2;
    position: fixed;
    left: 0;
    right: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.tag-bubbles-row.sub-row {
    padding: 4px 6px !important;
    height: var(--sub-tag-row-height);
    gap: 4px;
    font-size: 0.8em;
}

.tag-bubbles-row.sub-row .tag-bubble,
.tag-bubbles-row.sub-row .trip-bubble,
.tag-bubbles-row.sub-row .sort-bubble {
    font-size: 0.8em;
    padding: 4px 8px;
}

/* -----------------------------------------------------------
   CUSTOM DROPDOWNS
----------------------------------------------------------- */
.custom-dropdown {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 50px;
    border-radius: 16px;
    cursor: pointer;
    overflow: visible;
}

.custom-dropdown.active {
    background-color: var(--accent) !important;
}

.dropdown-btn {
    width: 100vw;
    height: 80px;
    background-color: transparent;
    border: None;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#page-gallery .filter-bar .dropdown-btn {
    width: 100%;
    height: 100%;
}
#page-gallery .filter-bar .has-badge .dropdown-btn {
    height: 37px; /* the search box is 35px plus its 1px border, top and bottom */
}

.dropdown-btn i {
    pointer-events: none;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 50px;
    min-width: 80px;
    background-color: var(--primary);
    box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    z-index: 15;
    max-height: 250px;
    overflow-y: auto;
    white-space: nowrap;
}

.dropdown-content.show {
    display: block;
}

.dropdown-content div {
    padding: 8px 12px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    border-radius: 16px;
    gap: 5px;
    color: var(--secondary_grey);
    cursor: pointer;
}

@media (hover: hover) {
    .dropdown-content div:hover {
        background-color: var(--accent);
    }
}

.dropdown-content div.selected {
    background-color: var(--accent);
}

#categoryDropdown,
#sortDropdown,
#tripDropdown {
    display: none !important;
}

.tiny-square {
    position: relative;
    width: 50px;
    height: 50px;
    background-color: var(--secondary_grey);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (hover: hover) {
    .tiny-square:hover {
        background-color: var(--accent);
        color: var(--primary);
    }
}

.tiny-square select {
    width: 100%;
    height: 100%;
    font-size: 1.1rem;
    text-align: center;
    padding: 0;
    background-color: transparent;
    border: none;
    outline: none;
}

/* -----------------------------------------------------------
   MAIN CONTENT & GRID
----------------------------------------------------------- */
.content {
    margin-top: calc(var(--filter-bar-height) + var(--tag-row-height));
    flex: 1 0 auto;
}

#tripHeader {
    text-align: center;
    margin: 20px 0;
}

#tripHeader:empty {
    margin: 0;
    padding: 0;
}

#tripHeader h1 {
    font-size: 2em;
    margin-bottom: 10px;
}

#tripHeader p {
    font-size: 1.2em;
    color: var(--secondary_grey);
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    font-size: 1.2rem;
    text-align: justify;
    text-align-last: center;
    line-height: 1.7;
}

#pig {
    margin: 4px;
}

#pig .pig-figure {
    border-radius: var(--pig-radius, 0px);
}

.pig-sep-custom {
    font-family: var(--global-font);
    font-weight: 500;
    color: var(--secondary_grey);
    font-size: 0.9em;
    padding: 8px 16px;
    text-align: left;
}

.no-images-message {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    max-width: 400px;
    margin: 40px auto;
    padding: 20px 30px;
    color: #555;
    font-family: sans-serif;
    font-size: 1.1rem;
    text-align: center;
    transition: background-color 0.3s ease;
}

/* -----------------------------------------------------------
   MODAL (IMAGE & VIDEO)
----------------------------------------------------------- */
.modal {
    display: none;
    position: fixed;
    z-index: 20;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    align-items: center; /* Keep this if you use display: flex */
    justify-content: center;
}

@keyframes zoom {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

#modalImage.grab {
    cursor: grab;
}

#modalImage.grabbing {
    cursor: grabbing;
}

/* -----------------------------------------------------------
   MODAL UI & CONTROLS
----------------------------------------------------------- */
.close,
.info-button,
.download-button,
.slideshow-button,
.fullscreen-button {
    position: absolute;
    color: white;
    font-size: 30px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 420;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
    touch-action: manipulation;
}

.close::before,
.download-button::before,
.slideshow-button::before,
.fullscreen-button::before {
    content: '';
    position: absolute;
    inset: -10px;
}

@media (hover: hover) {
    .fullscreen-button:hover,
    .info-button:hover,
    .close:hover,
    .slideshow-button:hover,
    .download-button:hover {
        color: var(--accent);
    }
}

.close {
    top: 5px;
    right: 25px;
}

.info-button {
    top: 5px;
    right: 165px;
}

.info-button.info-open {
    color: var(--accent);
}

.download-button {
    top: 5px;
    right: 130px;
}

.fullscreen-button {
    top: 5px;
    right: 60px;
}
.slideshow-button {
    top: 5px;
    right: 95px;
}

#resetZoomBtn {
    position: absolute;
    top: 10px;
    right: 20px;
    z-index: 22;
    padding: 8px 16px;
    cursor: pointer;
    display: none;
}

/* 360° photos: "Look around" pill above the preview row, and the Pannellum
   viewer that fades in over the slide (under the modal controls). */
#sphereBtn,
#resetZoomBtn {
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font: inherit;
    font-size: 15px;
    touch-action: manipulation;
}
#sphereBtn {
    position: absolute;
    left: 50%;
    bottom: calc(90px + var(--safe-bottom, 0px));
    transform: translateX(-50%);
    z-index: 25;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    cursor: pointer;
}
/* A square icon box, centred by the button, so the spin doesn't wobble. */
#sphereBtn i {
    display: flex;
}
#sphereBtn i::before {
    vertical-align: top;
}
#sphereBtn.loading {
    cursor: progress;
}
#sphereBtn.loading i {
    animation: sphere-spin 1s linear infinite;
}
@keyframes sphere-spin {
    to {
        transform: rotate(360deg);
    }
}
@media (prefers-reduced-motion: reduce) {
    #sphereBtn.loading i {
        animation: sphere-pulse 1.2s ease-in-out infinite alternate;
    }
    @keyframes sphere-pulse {
        to {
            opacity: 0.35;
        }
    }
}
#sphereViewer {
    position: absolute;
    inset: 0;
    z-index: 23;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease-out;
}
#sphereViewer.open {
    opacity: 1;
    pointer-events: auto;
}
#sphereCanvas,
.sphere-layer {
    position: absolute;
    inset: 0;
}
#sphereCanvas .pnlm-container {
    background: black;
}
#sphereCanvas .pnlm-load-box,
#sphereCanvas .pnlm-about-msg {
    display: none !important;
}

/* -----------------------------------------------------------
   MODAL CAPTION & INFO PANEL
----------------------------------------------------------- */

.modal-caption-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 165px;
    width: auto;
    display: flex;
    justify-content: flex-start;
    pointer-events: none;
    z-index: 25;
    height: 30px;
}

@media (max-width: 900px) {
    .modal-caption-container {
        right: 130px;
    }
}

.modal-caption {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    max-width: 100%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 6px 16px;
    border-radius: 16px;
    box-sizing: border-box;
    pointer-events: auto;
    cursor: pointer;
    text-align: left;
    font-size: 1rem;
    line-height: 1.2;
    font-feature-settings:
        'liga' 0,
        'kern' 0;
    text-rendering: geometricPrecision;
    transition: background-color 0.2s;
}

.modal-caption-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-caption-info {
    flex: 0 0 auto;
    font-size: 0.95em;
    opacity: 0.85;
}

/* Photo ID after the caption — quieter than the caption, so it reads as a
   reference, not part of the title. */
.modal-caption-code {
    flex: 0 0 auto;
    font-size: 0.78em;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

@media (hover: hover) {
    .modal-caption:hover {
        background: rgba(0, 0, 0, 0.7);
    }
    .modal-caption:hover .modal-caption-info {
        opacity: 1;
        color: var(--accent);
    }
}

.modal-caption.info-open .modal-caption-info {
    color: var(--accent);
    opacity: 1;
}

.info-button {
    display: none !important;
}

.info-panel-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    outline: none;
    border-radius: 50%;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.65);
    font-size: 16px;
    line-height: 1;
    padding: 0;
    z-index: 2;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.info-panel-close::before {
    content: '';
    position: absolute;
    inset: -8px;
}

.photo-license {
    font-size: 0.72em;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.02em;
    pointer-events: auto;
    margin-left: auto;
}
.photo-license a,
.photo-license span {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.25);
}
@media (hover: hover) {
    .photo-license a:hover {
        color: var(--accent);
        border-bottom-color: var(--accent);
    }
}

@keyframes thumb-border-pulse {
    0%,
    100% {
        border-color: rgba(255, 255, 255, 0.2);
    }
    50% {
        border-color: rgba(255, 255, 255, 0.9);
    }
}

.thumb-loading {
    animation: thumb-border-pulse 1.3s ease-in-out infinite !important;
}

@media (hover: hover) {
    .info-panel-close:hover {
        color: #fff;
        background: rgba(255, 255, 255, 0.18);
    }
}

.stars-views-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    min-height: 18px;
}

.photo-view-count {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
}

.info-panel-footer {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-top: 4px;
    min-height: 20px;
}

.info-panel-footer .photo-license {
    align-self: baseline;
    margin-left: auto;
}

/* Mobile download button (lives in info panel footer; hidden on desktop) */
button.download-btn-mobile,
button.download-btn-mobile:disabled {
    border: none;
    outline: none;
    background-color: transparent;
    box-shadow: none;
}

@media (hover: hover) {
    button.download-btn-mobile:hover,
    button.download-btn-mobile:disabled:hover {
        border: none;
        outline: none;
        background-color: transparent;
        box-shadow: none;
    }
}
button.download-btn-mobile {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.72em;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition:
        background-color 0.15s,
        color 0.15s;
    white-space: nowrap;
    border-radius: 50px;
    display: none;
}
/* Only the leftmost footer button needs the negative margin to align with
   the panel's content edge (the other footer items shouldn't shift). */
.info-panel-footer > button:first-child {
    margin-left: -8px;
}
button.download-btn-mobile i {
    margin-right: 3px;
}
@media (hover: hover) {
    button.download-btn-mobile:not(:disabled):hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.85);
    }
}
@media (max-width: 900px) {
    button.download-btn-mobile {
        display: inline-flex;
        align-items: center;
    }
    /* The top-right download icon doesn't fit alongside the other modal buttons
     on narrow screens — hide it; the footer button takes over. */
    .download-button {
        display: none !important;
    }
    /* Without the top download button, info button slides into its slot. */
    .info-button {
        right: 130px;
    }
}

/* Photo ID chip beside the title in the info panel. Click copies the ?p= link. */
button.photo-code-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    vertical-align: middle;
    margin-left: 8px;
    padding: 2px 8px 2px 7px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.68em;
    font-weight: 500;
    letter-spacing: 0.05em;
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    cursor: pointer;
    outline: none;
    box-shadow: none;
    transition:
        background-color 0.15s,
        color 0.15s,
        border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
button.photo-code-chip .photo-code-chip-label {
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    letter-spacing: 0.08em;
}
button.photo-code-chip i {
    font-size: 0.85em;
    opacity: 0.6;
}
@media (hover: hover) {
    button.photo-code-chip:hover {
        background: rgba(255, 255, 255, 0.14);
        border-color: rgba(255, 255, 255, 0.35);
        color: #fff;
        box-shadow: none;
    }
    button.photo-code-chip:hover i {
        opacity: 1;
    }
}

/* The uncompressed toggle cycles through three labels; a fixed width keeps
   the footer row from jumping as they change. */
button.uncompressed-toggle {
    min-width: 10.5em;
    text-align: center;
}

/* Use button.uncompressed-btn (specificity 0,1,1) to beat the global button:hover (0,1,1)
   via source order, and button.uncompressed-btn:hover (0,2,1) to beat it outright */
button.uncompressed-btn,
button.uncompressed-btn:disabled {
    border: none;
    outline: none;
    background-color: transparent;
    box-shadow: none;
}

@media (hover: hover) {
    button.uncompressed-btn:hover,
    button.uncompressed-btn:disabled:hover {
        border: none;
        outline: none;
        background-color: transparent;
        box-shadow: none;
    }
}
button.uncompressed-btn {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.72em;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition:
        background-color 0.15s,
        color 0.15s;
    white-space: nowrap;
    border-radius: 50px;
}
button.uncompressed-btn:disabled {
    cursor: default;
    color: rgba(255, 255, 255, 0.45);
}
@media (hover: hover) {
    button.uncompressed-btn:not(:disabled):hover {
        background-color: rgba(255, 255, 255, 0.1);
        color: rgba(255, 255, 255, 0.85);
    }
}

.info-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.98);
    color: var(--primary);
    padding: 20px;
    box-sizing: border-box;
    border-radius: 16px 16px 0 0; /* Add radius to top corners only */
    font-size: 14px;
    line-height: 1;
    z-index: 999;
    /* iOS Safari/Chrome auto-inflates inherited text it deems "too small to
     read", which skips elements with explicit font-size (the h3 title) but
     enlarges the inherited body rows. Lock the adjustment so the explicit
     sizes are honoured. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.info-panel h3 {
    margin: 0 0 10px;
    font-size: 16px;
    padding-right: 36px;
    /* Title, creator and ID chip flow as flex items so that when they wrap on a
     narrow screen each piece starts flush left with a real gap above it, rather
     than an inline chip landing indented and touching the line above (the
     panel's line-height is 1). */
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 8px;
    row-gap: 6px;
    line-height: 1.25;
    min-width: 0;
}
.info-panel h3 > .searchable,
.info-panel h3 > .creator {
    min-width: 0;
    overflow-wrap: anywhere;
}
.info-panel h3 > button.photo-code-chip {
    margin-left: 0; /* spacing comes from the h3 gap */
    flex-shrink: 0;
}

.info-panel .creator {
    font-size: 0.8em;
    color: var(--primary_grey);
}

.info-panel .info-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-panel .info-item {
    margin-bottom: 8px;
}

.info-panel .info-icon {
    font-size: 1.2em;
    color: var(--secondary_grey);
    margin-right: 4px;
}

/* -----------------------------------------------------------
   MODAL PREVIEW ROW
----------------------------------------------------------- */
#previewRow {
    position: absolute;
    bottom: 10px;
    height: 60px;
    overflow-x: auto;
    overflow-y: visible;
    width: calc(100vw - 20px);
    left: 10px;
    box-sizing: border-box;
    z-index: 22;
    /* Native horizontal scrolling: flicks, momentum and edge bounce come from the
     browser. pan-x keeps a vertical drag here from being taken as page scroll. */
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

#previewRow::-webkit-scrollbar {
    display: none;
}

#previewRow img {
    border: 2px solid var(--secondary_grey);
    border-radius: 8px;
    cursor: pointer;
    transition:
        border-color 0.3s,
        transform 0.2s,
        translateY(0);
    transform: scale(0.85);
    -webkit-user-drag: none;
    margin-right: 8px;
    margin-top: 3px;
    opacity: 1;
    will-change: transform, opacity;
    display: flex !important;
}

#previewRow.hidden {
    /* This slides it down (e.g., 100px) and fades it out */
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none; /* Disables clicks when hidden */
}

@media (hover: hover) {
    #previewRow img:hover {
        transform: scale(0.9);
    }
}

#previewRow img.selected {
    border-color: var(--primary) !important;
}

/* Decorative play badge over video thumbnails in the modal preview row. */
.preview-video-badge {
    position: absolute;
    width: 18px;
    height: 18px;
    margin-top: 3px; /* match the 3px top margin on #previewRow img */
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 8px;
    padding-left: 1px; /* optical centering for the play glyph */
    pointer-events: none; /* clicks belong to the thumbnail underneath */
    z-index: 1;
}

#previewRow.hidden {
    /* This slides it down (e.g., 100px) and fades it out */
    transform: translateY(100px);
    opacity: 0;
    pointer-events: none; /* Disables clicks when hidden */
}

/* -----------------------------------------------------------
   SUBSCRIPTION MODAL
----------------------------------------------------------- */
#subscribeModal .subscribe-inner {
    background: var(--primary);
    color: var(--secondary);
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 400px;
    margin: 50px auto;
    text-align: center;
}

#subscribeModal input[type='email'] {
    width: 90%;
    max-width: 300px;
    padding: 10px;
    margin: 0 auto 10px;
    font-size: 16px;
    display: block;
    background-color: var(--primary);
    color: var(--secondary);
    border: 2px solid var(--secondary);
    border-radius: 16px;
}

#subscribeModal input[type='email']:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent);
}

#subscribeModal button {
    padding: 5px 16px;
    font-size: 12px;
    border: none;
    color: var(--primary);
    border-radius: 16px;
    cursor: pointer;
    margin-bottom: 10px;
}

.subscribe-info {
    font-size: 0.9em;
    color: var(--secondary_grey);
    margin-top: 10px;
}

/* -----------------------------------------------------------
   GENERAL INTERACTIVE & EMBED STYLES
----------------------------------------------------------- */
.searchable {
    cursor: pointer;
}

@media (hover: hover) {
    .searchable:hover {
        color: var(--accent);
        text-decoration: none;
    }
}

.keyword {
    font-size: 0.4em;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
}

@media (hover: hover) {
    .keyword:hover {
        color: var(--secondary_grey);
    }
}

.hide-on-gallery {
    display: none;
}

body.embed-mode .filter-bar {
    display: none !important;
}

body.embed-mode .content {
    margin-top: 0 !important;
}

body.embed-mode #pig {
    margin: 0 !important;
}

body.embed-mode .info-panel .searchable,
body.embed-mode .info-panel .tag-bubble,
body.embed-mode .info-panel .star-rating {
    pointer-events: none !important;
    cursor: default !important;
}

#homepageTextBlock {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* -----------------------------------------------------------
   STATIC PAGE STYLES
----------------------------------------------------------- */
.top-bar-static {
    padding: 10px 20px;
    background-color: var(--primary);
    border-bottom: 1px solid var(--primary_grey);
}

.page-content-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    font-size: 1rem;
    text-align: justify;
    line-height: 1.7;
    color: var(--secondary-color);
}

.page-content-wrapper h1,
.page-content-wrapper h2,
.page-content-wrapper h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.page-content-wrapper p {
    margin-bottom: 1em;
}

/* Links written in a text or HTML block (pills, tiles and album rows are styled in pages.css) */
.page-content-wrapper .pg-block a:not(.nw-link) {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent);
}

@media (hover: hover) {
    .page-content-wrapper .pg-block a:not(.nw-link):hover {
        background-color: var(--accent);
        color: var(--primary);
    }
}

/* -----------------------------------------------------------
   BOTTOM NAVIGATION DOCK
----------------------------------------------------------- */
.bottom-nav-dock {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    background: white;
    border-radius: 999px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.05),
        0 8px 24px rgba(0, 0, 0, 0.16);
    transition:
        transform 0.3s ease,
        opacity 0.3s ease;
}

.bottom-nav-dock.off-screen {
    transform: translate(-50%, 160%);
    opacity: 0;
    pointer-events: none;
}

.bottom-nav-dock a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-sizing: border-box;
    min-width: 56px;
    height: 48px;
    padding: 0 14px;
    color: #6b6b6b;
    text-decoration: none;
    border-radius: inherit;
    transition:
        background-color 0.2s ease-in-out,
        color 0.2s ease-in-out;
}

.bottom-nav-dock a i {
    font-size: 18px;
}

.bottom-nav-dock a span {
    font-size: 11px;
    letter-spacing: 0.01em;
}

/* The open page fills its button edge to edge: no gap round the accent. */
.bottom-nav-dock a.active {
    color: #18200d;
    background-color: var(--accent);
}

@media (hover: hover) {
    .bottom-nav-dock a:not(.active):hover {
        color: #111;
    }
}

/* Grid, Mix and Gallery share a pale tray. Off the photo pages it is just the
   Gallery button: the others fold to nothing and the tray goes clear. One
   accent thumb sits under the open view. The script under the dock in
   index.php animates every change between these states. */
.bottom-nav-dock .dock-views {
    position: relative;
    display: flex;
    border-radius: inherit;
    background-color: #dfe4d5;
    transition: background-color 0.32s ease;
}
.bottom-nav-dock .dock-views::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--thumb-w, 0);
    transform: translateX(var(--thumb-x, 0));
    border-radius: inherit;
    background-color: var(--accent);
}
.bottom-nav-dock .dock-views a {
    position: relative; /* above the thumb */
    overflow: hidden;
}
.bottom-nav-dock .dock-views a.active {
    background-color: transparent;
}
body:not(.gallery-active) .bottom-nav-dock .dock-views {
    background-color: transparent;
}
body:not(.gallery-active) .bottom-nav-dock .dock-views::before {
    opacity: 0;
}
body:not(.gallery-active) .bottom-nav-dock .dock-views a:not([data-page='gallery']) {
    width: 0;
    min-width: 0;
    padding: 0;
    opacity: 0;
    visibility: hidden;
}

/* Up to ten items: the dock never leaves the viewport and labels never
   wrap or truncate. On a phone the whole dock scales down uniformly
   (--dock-scale, set by the fitDock script in index.php) until every label
   fits in full — full text always beats an ellipsis. */
.bottom-nav-dock {
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
    --dock-scale: 1;
}
/* One width for every short label, so the accent pill and the view thumb are
   the same shape whichever is selected. Longer labels still grow. */
.bottom-nav-dock a {
    min-width: 64px;
}
.bottom-nav-dock a span {
    white-space: nowrap;
}
@media (max-width: 640px) {
    .bottom-nav-dock a {
        flex: 0 0 auto;
        min-width: calc(58px * var(--dock-scale));
        height: calc(48px * var(--dock-scale));
        padding: 0 calc(10px * var(--dock-scale));
    }
    .bottom-nav-dock a i {
        font-size: calc(18px * var(--dock-scale));
    }
    .bottom-nav-dock a span {
        font-size: calc(10.5px * var(--dock-scale));
    }
}

/* Home, About and custom pages: the page's own background (colour or photo)
   runs to the bottom of the window. The section grows to fill the body (a flex
   column) and keeps room for the dock at its foot. There is no footer. */
body:not(.gallery-active) #pagesWrapper {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}
body:not(.gallery-active) .page-section:not([hidden]) {
    flex: 1 0 auto;
    padding-bottom: 100px;
}

.settings-icon {
    margin-top: 10px;
    display: inline-block;
    color: var(--secondary_grey);
    font-size: 10px;
    transition: color 0.3s;
}
/* Find and replace the old rule with this one */
body.gallery-active .site-header {
    display: none;
}
/*
 * Styles for images embedded via Markdown in main content areas.
 * This makes them display as centered, responsive blocks.
 */
.page-content-wrapper p > img,
.photo-group-card-content p > img,
#tripHeader p > img {
    display: block; /* Makes the image a block element, forcing it onto a new line. */
    max-height: 500px; /* Sets the maximum width to 500px, as requested. */
    height: calc(80% - 64px); /* Ensures the image is responsive and shrinks on smaller screens. */
    margin: 10px auto;
    border-radius: 12px; /* Optional: Adds a nice rounded corner. */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Optional: Adds a subtle shadow for depth. */
}

.card {
    background: var(--primary);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    margin-bottom: 2rem;
}
@media (max-width: 900px) {
    .main-content {
        width: 100% !important;
        padding-left: 0px;
        padding-right: 22px;
    }

    .card {
        margin: 10px !important;
        width: 100% !important;
    }

    .page-content-wrapper,
    #tripHeader p {
        font-size: 0.9rem;
    }

    .info-panel {
        font-size: 10px;
    }
    .info-panel h3 {
        margin: 0 0 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 0.75rem;
    }
}

/* --- ✅ NEW: Style for Section Divider --- */
hr.section-divider {
    border: 0;
    height: 1px;
    background-color: var(--primary_grey);
    margin: 10px auto;
    max-width: 1200px;
    width: calc(100vw - 40px);
}

/* Container for keyword blocks */
.tags-container {
    margin-top: 1rem;
}

/* A block for a single subject's keywords */
.subject-keywords {
    margin-bottom: 0.5rem;
}

/* Base style for all tags */
.keyword-tag {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.6rem; /* 12px */
    font-weight: 400;
    margin-right: 3px;
    margin-bottom: 3px;
    border-radius: 9999px; /* pill shape */
    line-height: 1.5;
    text-transform: capitalize; /* Title Case looks nice */
    transition: transform 0.1s ease-in-out;
}

/* Make tags clickable */
.keyword-tag.searchable {
    cursor: pointer;
}

@media (hover: hover) {
    .keyword-tag.searchable:hover {
        transform: translateY(-2px);
        filter: brightness(1.1);
    }
}

/* Specific tag styles */
.keyword-tag.name {
    background-color: #fef3c7; /* blue-500 */
    color: #92400e;
}

.keyword-tag.category {
    background-color: #e5e7eb; /* gray-200 */
    color: #374151; /* gray-700 */
}

/* ✨ NEW: Style for subcategory */
.keyword-tag.subcategory {
    background-color: #e0e7ff; /* indigo-100 */
    color: #3730a3; /* indigo-800 */
}

/* ✨ NEW: Style for sub-subcategory */
.keyword-tag.subsubcategory {
    background-color: #fce7f3; /* pink-100 */
    color: #9d266b; /* pink-800 */
}

.keyword-tag.family {
    background-color: #d1fae5; /* green-100 */
    color: #065f46; /* green-800 */
}

.keyword-tag.attribute {
    background-color: #fef3c7; /* amber-100 */
    color: #92400e; /* amber-800 */
    font-style: italic;
    cursor: default; /* Attributes aren't clickable */
    text-transform: none; /* Keep attribute case as-is */
    display: none;
}

/* Timezone offset bubble shown next to the (local) capture time in the info panel */
.tz-bubble {
    display: inline-block;
    padding: 0 5px;
    font-size: 0.6rem;
    font-weight: 600;
    line-height: 1.6;
    /* `middle` centres a 0.6rem pill on the x-height of the surrounding text,
       which lands it visibly below the digits. Lift it onto their centre line. */
    vertical-align: 0.2em;
    border-radius: 9999px;
    background-color: rgba(255, 255, 255, 0.15);
    color: #ddd;
    cursor: default;
}

.droppable-zone.dragover {
    /* A dashed outline appears inside the element */
    outline: 3px dashed #4a90e2;
    outline-offset: -10px; /* Pulls the outline inside the padding */

    /* A light blue background tint */
    background-color: rgba(74, 144, 226, 0.1) !important;
    transition:
        outline 0.2s ease-in-out,
        background-color 0.2s ease-in-out;
    z-index: 2000;
}

/* --- Toast Notification CSS --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.toast {
    background-color: #333;
    color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    min-width: 280px;
    font-family: var(--global-font);
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast i {
    font-size: 1.4em;
}

/* Different toast types for context */
.toast.info {
    background-color: var(--secondary_grey);
    color: var(--primary);
}
.toast.info i {
    color: var(--accent);
}

.toast.success {
    background-color: #28a745; /* A standard green */
    color: white;
}
.toast.success i {
    color: #c3e6cb;
}

.toast.error {
    background-color: var(--red);
    color: white;
}
.toast.error i {
    color: #f5c6cb;
}

/* --- Trip Info Bar Container Styles --- */

.trip-info-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    box-sizing: border-box;
    color: rgb(255, 255, 255);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    z-index: 1;
}

/* --- State 2: No Cover Photo (Light Bar) Container Styles --- */
.trip-cover-header:not([style*='overflow: hidden']) .trip-info-bar {
    border-radius: 16px;
    position: relative; /* Change to relative so it sits below the title */
    color: var(--secondary);
    margin-top: 1.5rem; /* Add some space from the title */
    padding: 0.6rem 1rem;
    text-shadow: none; /* Remove shadow on light background */
}

.info-bar-left,
.info-bar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.info-bar-left {
    gap: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* --- Consolidated Bubble/Button Styling (Shape and Size) --- */
/* Applies to date, tags, and buttons for a consistent, bubble-like appearance */
.info-bar-date,
.info-bar-tag,
.info-bar-btn {
    padding: 0.3rem 0.6rem;
    border-radius: 16px; /* Uniform rounded shape */
    box-sizing: border-box;
    white-space: nowrap;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.2s ease;
}

.info-bar-date {
    cursor: default; /* Date is not interactive */
}

.info-bar-tag {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem;
}

.info-bar-btn {
    cursor: pointer; /* Button is interactive */
}

/* --- State 1: Dark Bar (Cover Photo) Color Theme --- */
.trip-cover-header[style*='overflow: hidden'] .info-bar-date,
.trip-cover-header[style*='overflow: hidden'] .info-bar-tag,
.trip-cover-header[style*='overflow: hidden'] .info-bar-btn {
    color: white;
    background: rgb(72, 72, 72); /* Default transparent dark background */
}

@media (hover: hover) {
    .trip-cover-header[style*='overflow: hidden'] .info-bar-btn:hover {
        background: rgba(98, 98, 98);
    }
}

.info-bar-tag.tag-blog,
.info-bar-tag.tag-trip,
.info-bar-tag.tag-group {
    color: white; /* Ensure text is white on all colored tags */
}

/* Updated Tag-Specific Colors */
/* This will now override the generic background in State 1 (Dark Bar) as well! */
.trip-cover-header .info-bar-tag.tag-blog {
    background-color: #2ecc71;
}
.trip-cover-header .info-bar-tag.tag-trip {
    background-color: #3498db;
}
.trip-cover-header .info-bar-tag.tag-group {
    background-color: #e67e22;
}

@media (hover: hover) {
    .trip-cover-header:not([style*='overflow: hidden']) .info-bar-btn:hover {
        background: rgb(141, 141, 141);
    }
}
.trip-cover-header:not([style*='overflow: hidden']) .info-bar-btn,
.info-bar-date {
    background: rgb(129, 129, 129);
    color: white;
}

/* --- Tag-Specific Colors (Always overrides generic background in Light Bar state) --- */
.info-bar-tag.tag-blog,
.info-bar-tag.tag-trip,
.info-bar-tag.tag-group {
    color: white; /* Ensure text is white on all colored tags */
}
.info-bar-tag.tag-blog {
    background-color: #74bbd3;
}
.info-bar-tag.tag-trip {
    background-color: #e67e22;
}
.info-bar-tag.tag-group {
    background-color: #9b59b6;
}

/* --- Special Button Styles --- */
.info-bar-btn.all-btn {
    font-weight: 700;
    /* Inherits background/color from its respective state (Dark or Light) */
}

button.info-bar-btn {
    border: none;
    font-family: inherit;
}

@media (max-width: 900px) {
    .info-bar-date,
    .info-bar-tag,
    .info-bar-btn {
        font-size: 0.8rem;
        font-weight: 600;
    }

    .trip-info-bar {
        padding: 0.75rem 0.75rem;
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .info-bar-left,
    .info-bar-right {
        justify-content: center;
        flex-wrap: wrap;
        width: 100%;
    }
}

#modalPrevImage,
#modalNextImage {
    /* Match #modalImage styles */
    display: block;
    margin: 10px 10px;
    object-fit: contain;
    height: calc(100vh - 90px);
    width: calc(100vw - 20px);

    /* Positioning */
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20; /* Just behind modalImage (which is z-index: 21) */

    /* Start hidden and off-screen */
    opacity: 0;
    transform: translateX(-100vw); /* Default for prev */
}

#modalNextImage {
    transform: translateX(100vw); /* Default for next */
}

#modalImage {
    position: relative; /* Make sure this is relative */
    z-index: 21; /* Make sure this is higher */
}

/* -----------------------------------------------------------
   NEW: MODAL CAROUSEL STYLES
----------------------------------------------------------- */
#modalSliderTrack {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%; /* Holds three slides */
    display: flex;
    /* Start centered on the middle slide */
    transform: translateX(-100%);
    will-change: transform;
}
.modal-zoomed .modal-slide img {
    height: 100%;
    width: 100%;
    object-fit: contain;
}

.modal-slide {
    width: calc(100%); /* Each slide takes 1/3 of the track */
    height: calc(100% - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Prevent Panzoom overflow issues */
    flex-shrink: 0; /* Prevent slides from shrinking */
}
.modal-zoomed .modal-slide {
    height: 100%;
}
.modal-slide img {
    display: block;
    cursor: default;
    will-change: transform;
    position: relative;
    height: calc(100dvh - 114px);
    width: calc(100vw - 20px);
    object-fit: contain;
    top: 23px;
    /* no long-press image menu or text selection: see the contextmenu handler in modal.js */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}
/* The player (player.js / player.css) sized to the video's own aspect ratio
   (--video-ar, set from metadata in modal.js) inside the available box, so its
   controls sit on the picture rather than stretching to the screen edges. */
#modalPlayer {
    position: relative;
    --video-ar: 16 / 9;
    aspect-ratio: var(--video-ar);
    width: min(100vw, calc((100dvh - 114px) * var(--video-ar)));
    height: auto;
    max-height: calc(100dvh - 114px);
    z-index: 21;
    top: 23px;
}

@media (max-width: 900px) {
    .modal-slide img {
        width: 100vw;
    }
}

.modal-zoomed .modal-slide img {
    height: 100%;
    width: 100%;
    top: 0px;
}

/* Ensure Panzoom grabs work correctly */
.modal-slide img.grab {
    cursor: grab;
}

.modal-slide img.grabbing {
    cursor: grabbing;
}

/* Remove old peeking image styles if they exist */
#modalPrevImage,
#modalNextImage {
    display: none !important;
}

/* Adjustments for positioning controls over the track */
#imageModal .modal-controls,
#imageModal #modalCaptionContainer,
#imageModal #previewRow,
#imageModal #resetZoomBtn {
    z-index: 25; /* Ensure controls are above the track (z-index 20) */
}
/* --- Info Panel Animation --- */
#infoPanel {
    visibility: hidden;
    opacity: 1; /* the panel slides, it never fades — see settleInfoPanel() in modal.js */
    transform: translateY(100%); /* Start hidden off-screen */
    transition:
        transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
        visibility 260ms;
    z-index: 999;
}

#imageModal.modal-info-panel-open #infoPanel {
    visibility: visible !important;
    transform: translateY(0);
}

.arrow {
    cursor: pointer;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    color: var(--primary);
    font-weight: 100;
    font-size: 20px;
    transition:
        background-color 0.3s ease,
        opacity 0.3s ease;
    background-color: rgba(0, 0, 0, 0);
    z-index: 1;
}

@media (hover: hover) {
    .arrow:hover {
        background-color: rgba(0, 0, 0, 0.2);
        opacity: 1;
    }
}

.arrow.left {
    left: 0;
}

.arrow.right {
    right: 0;
}

@media (max-width: 900px) {
    .arrow {
        display: none !important;
    }
}

/* --- NEW: Mini Trip Cards --- */
.tag-bubbles-row.sub-row.trip-cards-mode {
    height: auto;
    padding: 10px 10px !important;
    gap: 12px;
}

.trip-card-mini {
    position: relative;
    flex: 0 0 auto;
    width: 140px;
    height: 80px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    background-color: var(--primary_grey);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

@media (hover: hover) {
    .trip-card-mini:hover {
        transform: translateY(-3px);
        box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
    }
}

.trip-card-mini-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: brightness(0.6); /* Dims the image so white text pops */
    transition: filter 0.2s ease;
}

@media (hover: hover) {
    .trip-card-mini:hover .trip-card-mini-bg {
        filter: brightness(0.4); /* Darkens slightly on hover */
    }
}

.trip-card-mini-text {
    position: relative;
    z-index: 1;
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    padding: 0 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    white-space: normal; /* Lets long trip names wrap to a second line */
    line-height: 1.2;
}

.trip-card-mini.no-cover {
    background-color: var(--accent);
}

.trip-card-mini.no-cover .trip-card-mini-text {
    text-shadow: none; /* Removes text shadow if there is no image background */
}
/* --- Distinct Active Trip Bubble (Combined Country/Trip) --- */
.tag-bubbles-row .active-trip-bubble.selected {
    background-color: #cda4e8; /* Solid soft purple */
    border-color: #6a3d91; /* Darker purple border */
    color: #000;
}

@media (hover: hover) {
    .tag-bubbles-row .active-trip-bubble:hover {
        background-color: #b582d6; /* Slightly darker on hover */
        border-color: #6a3d91;
        color: #000;
    }
}

/* --- Video play button overlay on grid thumbnails --- */
.pig-video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

.pig-video-play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    padding-left: 3px; /* optical centering for play icon */
    backdrop-filter: blur(2px);
    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

/* 360° photos: same disc as the play button, with text instead of the icon */
.pig-sphere-tag {
    padding-left: 0;
    font-size: 12px;
    font-weight: 600;
}

/* Hover-to-preview: fade the play button out once the preview is rolling. */
.pig-video-overlay {
    transition: opacity 0.2s ease;
}

@media (hover: hover) {
    .pig-figure:hover .pig-video-play-btn,
    figure:hover .pig-video-play-btn {
        background: rgba(0, 0, 0, 0.75);
        transform: scale(1.1);
    }
}

/* ---------------------------------------------------------------------------
   TOUCH RESPONSIVENESS
   On a low-end Android tablet the filter/re-grid work costs a noticeable
   fraction of a second. These rules make the tap itself acknowledge instantly
   (press state paints in the same frame as the touch, independently of any JS)
   and give a restrained "working" cue only when the rebuild actually runs long.
--------------------------------------------------------------------------- */
.tag-bubbles-row .sort-bubble,
.tag-bubbles-row .tag-bubble,
.tag-bubbles-row .trip-bubble,
.tag-bubble,
.bottom-nav-dock a,
.subcategory-row span {
    touch-action: manipulation; /* no double-tap-zoom delay */
    -webkit-tap-highlight-color: transparent;
}

.tag-bubbles-row .sort-bubble:active,
.tag-bubbles-row .tag-bubble:active,
.tag-bubbles-row .trip-bubble:active,
.tag-bubble:active,
.subcategory-row span:active {
    transform: scale(0.93);
    filter: brightness(0.9);
    transition:
        transform 60ms ease-out,
        filter 60ms ease-out;
}

.bottom-nav-dock a:active {
    background-color: rgba(0, 0, 0, 0.06);
    transform: scale(0.95);
}

/* The grid dims slightly while it is being rebuilt — but the 180ms delay on the
   transition means a fast device finishes first and the cue never appears. */
#pig {
    transition: opacity 120ms ease;
}
body.grid-rebuilding #pig {
    opacity: 0.45;
    transition: opacity 120ms ease 180ms;
    pointer-events: none;
}

/* -----------------------------------------------------------
   PAGE TRANSITIONS
   showPage() in index.php wraps each tapped page or view change in a View
   Transition. The new screen fades in over the old one: Grid to Gallery
   zooms in (data-vt="in"), back zooms out, other pages rise slightly. The
   dock and bars are left out of the fade so they stay still, and the dock
   shows live so its own tray animation plays. Browsers without View
   Transitions just swap, as before.
   ----------------------------------------------------------- */
.bottom-nav-dock {
    view-transition-name: dock;
}
/* The search bar and tag rows are each fixed on their own (.top-bar itself
   is 0px tall, so naming it captured nothing and the bar vanished mid-fade). */
.filter-bar {
    view-transition-name: search-bar;
}
#tagBubblesRow {
    view-transition-name: tag-row;
}
#subTagBubblesRow {
    view-transition-name: sub-tag-row;
}
#tripSubRow {
    view-transition-name: trip-row;
}
.site-header {
    view-transition-name: site-header;
}
/* These stay live and in place for the whole switch: no snapshot, no fade. */
::view-transition-group(dock),
::view-transition-new(dock),
::view-transition-group(search-bar),
::view-transition-new(search-bar),
::view-transition-group(tag-row),
::view-transition-new(tag-row),
::view-transition-group(sub-tag-row),
::view-transition-new(sub-tag-row),
::view-transition-group(trip-row),
::view-transition-new(trip-row) {
    animation: none;
}
::view-transition-old(dock),
::view-transition-old(search-bar),
::view-transition-old(tag-row),
::view-transition-old(sub-tag-row),
::view-transition-old(trip-row) {
    display: none;
}
/* Entering or leaving the photos (About to Grid), the bars fade with the page. */
::view-transition-new(search-bar):only-child,
::view-transition-new(tag-row):only-child,
::view-transition-new(sub-tag-row):only-child,
::view-transition-new(trip-row):only-child {
    animation: vt-rise 280ms cubic-bezier(0.3, 0.7, 0.2, 1) both;
}
::view-transition-old(search-bar):only-child,
::view-transition-old(tag-row):only-child,
::view-transition-old(sub-tag-row):only-child,
::view-transition-old(trip-row):only-child {
    display: block;
    animation: vt-fade-out 150ms ease both;
}
@keyframes vt-fade-out {
    to {
        opacity: 0;
    }
}
/* Old stays solid underneath, new fades in on top: a crossfade with no
   see-through dip in the middle. */
::view-transition-old(root),
::view-transition-new(root) {
    mix-blend-mode: normal;
}
::view-transition-old(root) {
    animation: none;
}
::view-transition-new(root) {
    animation: vt-rise 280ms cubic-bezier(0.3, 0.7, 0.2, 1) both;
}
:root[data-vt='in']::view-transition-new(root) {
    animation-name: vt-zoom-in;
}
:root[data-vt='out']::view-transition-new(root) {
    animation-name: vt-zoom-out;
}
@keyframes vt-rise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}
@keyframes vt-zoom-in {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
}
@keyframes vt-zoom-out {
    from {
        opacity: 0;
        transform: scale(1.03);
    }
}

/* -----------------------------------------------------------
   MOBILE APP SAFE AREAS
   Applied only when running inside the Capacitor app (the .in-app class is set
   by the script next to the viewport meta in index.php). In a normal browser
   the OS chrome already keeps content clear of the notch/Dynamic Island, so
   none of this should apply there.

   Only --filter-bar-height is adjusted: the tag rows and the gallery are all
   positioned with calc() off that variable, so growing it moves everything
   below the bar down by exactly the inset. env() supplies the real per-device
   value, so this is correct on every notch, island and punch-hole without
   enumerating devices.
----------------------------------------------------------- */
html.in-app {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --filter-bar-height: calc(66px + var(--safe-top));
}
html.in-app .filter-bar {
    padding-top: calc(10px + var(--safe-top));
}
/* max(), not +: the dock already sat 20px up, which mostly clears the home
   indicator on its own. Adding the full inset on top stacked two gaps and
   pushed it visibly too high. */
html.in-app .bottom-nav-dock {
    bottom: max(20px, var(--safe-bottom));
}
html.in-app #toast-container {
    bottom: max(20px, var(--safe-bottom));
}

/* Stop the rubber-band overscroll dragging the page down past its top. */
html.in-app,
html.in-app body {
    overscroll-behavior-y: none;
}

/* Modal chrome. The image itself is deliberately left edge-to-edge — only the
   controls and caption move down, so fullscreen still fills the screen.
   On iOS requestFullscreen() on a <div> rejects and modal.js falls back to
   CSS-immersive mode, which hides these controls anyway; this only affects the
   normal modal view. */
html.in-app .close,
html.in-app .info-button,
html.in-app .download-button,
html.in-app .fullscreen-button,
html.in-app .slideshow-button {
    top: calc(5px + var(--safe-top));
}

html.in-app #resetZoomBtn,
html.in-app .modal-caption-container {
    top: calc(10px + var(--safe-top));
}

/* Landscape: the island/notch moves to a side, so the modal chrome needs the
   horizontal insets too. The image is untouched and stays edge-to-edge. */
html.in-app .close {
    right: calc(25px + var(--safe-right));
}
html.in-app .info-button {
    right: calc(165px + var(--safe-right));
}
html.in-app .download-button {
    right: calc(130px + var(--safe-right));
}
html.in-app .fullscreen-button {
    right: calc(60px + var(--safe-right));
}
html.in-app .slideshow-button {
    right: calc(95px + var(--safe-right));
}
html.in-app #resetZoomBtn {
    right: calc(20px + var(--safe-right));
}

html.in-app .modal-caption-container {
    left: calc(10px + var(--safe-left));
    right: calc(165px + var(--safe-right));
}
@media (max-width: 900px) {
    html.in-app .modal-caption-container {
        right: calc(130px + var(--safe-right));
    }
}

/* -----------------------------------------------------------
   PHOTO PAGE (?p=CODE) — server-rendered details block
   Real content for crawlers, sitting under the grid; the modal
   opens over the grid so a visitor sees this only on scrolling.
   See inc/photo_seo.php.
----------------------------------------------------------- */
.photo-page {
    max-width: 900px;
    margin: 24px auto 16px;
    padding: 0 16px;
    color: var(--secondary);
}
.photo-page figure {
    margin: 0;
}
.photo-page img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
}
.photo-page h1 {
    font-size: 1.4rem;
    margin: 16px 0 6px;
}
.photo-page__caption {
    margin: 0 0 12px;
    line-height: 1.5;
}
.photo-page__facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px 24px;
    margin: 0;
    font-size: 14px;
}
.photo-page__facts div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.photo-page__facts dt {
    color: var(--secondary_grey);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.photo-page__facts dd {
    margin: 0;
}
.photo-page__facts a {
    color: inherit;
}
body.embed-mode .photo-page {
    display: none;
}

/* -----------------------------------------------------------
   PHOTO VIEWER ON TOUCH SCREENS
   The desktop controls are 30px glyphs 35px apart, each with a
   hit area 10px wider all round, so the hit areas overlapped and
   the later button won: fullscreen kept about 20px of its own,
   and taps on it often landed on slideshow or close. Here each
   button is a 44px box (Apple's minimum) laid edge to edge.
   #imageModal outranks the html.in-app position rules above.
----------------------------------------------------------- */
@media (pointer: coarse) {
    #imageModal .modal-btn {
        top: calc(2px + var(--safe-top, 0px));
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 26px;
    }
    #imageModal .modal-btn::before {
        inset: 0;
    }
    #imageModal .close {
        right: calc(6px + var(--safe-right, 0px));
    }
    #imageModal .fullscreen-button {
        right: calc(50px + var(--safe-right, 0px));
    }
    #imageModal .slideshow-button {
        right: calc(94px + var(--safe-right, 0px));
    }
    #imageModal .download-button {
        right: calc(138px + var(--safe-right, 0px));
    }
    /* Same 44px row as the buttons, so the title pill sits level with them. */
    #imageModal .modal-caption-container {
        top: calc(2px + var(--safe-top, 0px));
        height: 44px;
        align-items: center;
        right: calc(188px + var(--safe-right, 0px)); /* clears download too */
    }

    /* Info panel buttons were ~20px tall. */
    .info-panel-close {
        width: 44px;
        height: 44px;
        top: 6px;
        right: 6px;
    }
    button.download-btn-mobile,
    button.uncompressed-btn {
        padding: 10px 14px;
        font-size: 0.85em;
    }
    button.photo-code-chip {
        padding: 6px 10px;
    }
}
@media (pointer: coarse) and (max-width: 900px) {
    #imageModal .modal-caption-container {
        right: calc(144px + var(--safe-right, 0px)); /* download is hidden here */
    }
}
