/* ============================================================
   THOMAS GARDEA — ENDLESS GALLERY  (WP Coder: CSS tab)
   Theme: white-on-white brutalist minimalism, film grain,
   staircase motif — inspired by the Endless cover art.
   Everything is scoped under #tg-gallery so it can't collide
   with the WordPress theme.
   ============================================================ */

#tg-gallery {
    --tg-ink: #0a0a0a;
    --tg-paper: #ffffff;
    --tg-gray: #8a8a8a;
    --tg-line: #e6e6e6;
    --tg-font: "Helvetica Neue", Helvetica, Arial, sans-serif;

    position: relative;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: clamp(16px, 3vw, 40px);
    box-sizing: border-box;
    background: var(--tg-paper);
    color: var(--tg-ink);
    font-family: var(--tg-font);
    overflow: hidden;
}

#tg-gallery *,
#tg-gallery *::before,
#tg-gallery *::after { box-sizing: border-box; }

/* Film-grain overlay across the whole widget (the Endless texture) */
#tg-gallery::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 60;
    opacity: 0.5;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Hide the native cursor when the custom cursor is running (desktop only) */
@media (pointer: fine) {
    #tg-gallery.tg-has-cursor,
    #tg-gallery.tg-has-cursor * { cursor: none !important; }
}

/* ================= HEADER ================= */

#tg-gallery .tg-head {
    padding: 8px 0 20px;
}

#tg-gallery .tg-head-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 10px;
}

#tg-gallery .tg-eyebrow {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--tg-gray);
}

/* EN / ES switch — same pattern as the sports page's .lang-switch */
#tg-gallery .tg-lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    color: var(--tg-gray);
}

#tg-gallery .tg-lang-btn {
    background: none;
    border: none;
    padding: 8px 6px; /* generous hit area — the whole word is clickable */
    font: inherit;
    color: var(--tg-gray);
    letter-spacing: inherit;
    position: relative;
    cursor: pointer;
    transition: color 0.25s;
}

#tg-gallery .tg-lang-btn.is-active { color: var(--tg-ink); }

#tg-gallery .tg-lang-btn.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: var(--tg-ink);
}

#tg-gallery .tg-head-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

#tg-gallery .tg-title {
    margin: 0;
    font-size: clamp(44px, 8vw, 104px);
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.04em;
    text-transform: uppercase;
    color: var(--tg-ink);
}

#tg-gallery .tg-title-ghost {
    color: transparent;
    -webkit-text-stroke: 1.5px var(--tg-ink);
}

/* "Switch to Video" button — hidden until the tg-show-videobtn
   switch is added to the #tg-gallery class list in the HTML */
#tg-gallery .tg-video-btn {
    display: none;
    align-items: center;
    padding: 15px 28px;
    background: var(--tg-ink);
    color: var(--tg-paper);
    border: 1px solid var(--tg-ink);
    border-radius: 999px;
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    white-space: nowrap;
    flex: none;
    transition: background 0.3s ease, color 0.3s ease;
}

#tg-gallery.tg-show-videobtn .tg-video-btn { display: inline-flex; }

#tg-gallery .tg-video-btn:hover {
    background: var(--tg-paper);
    color: var(--tg-ink);
}

/* Option switches (set on the #tg-gallery class list in the HTML) */
#tg-gallery.tg-hide-caption .tg-preview-caption { display: none; }
#tg-gallery.tg-hide-count .tg-tab-count { display: none; }

#tg-gallery .tg-sub {
    margin: 14px 0 0;
    max-width: 520px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--tg-gray);
}

/* ================= TICKER ================= */

#tg-gallery .tg-ticker {
    overflow: hidden;
    border-top: 1px solid var(--tg-ink);
    border-bottom: 1px solid var(--tg-ink);
    padding: 9px 0;
    margin: 18px 0 0;
    white-space: nowrap;
}

#tg-gallery .tg-ticker-track {
    display: inline-flex;
    animation: tg-ticker 28s linear infinite;
}

#tg-gallery .tg-ticker-track span {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--tg-ink);
    padding-right: 8px;
}

@keyframes tg-ticker {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* ================= TABS ================= */

#tg-gallery .tg-tabs {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: clamp(18px, 4vw, 56px);
    margin: 0 0 26px;
    border-bottom: 1px solid var(--tg-line);
    overflow-x: auto;
    scrollbar-width: none;
}
#tg-gallery .tg-tabs::-webkit-scrollbar { display: none; }

#tg-gallery .tg-tab {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 22px 2px 18px;
    background: none;
    border: none;
    font-family: var(--tg-font);
    color: var(--tg-gray);
    cursor: pointer;
    flex: none;
    transition: color 0.35s ease;
    -webkit-tap-highlight-color: transparent;
}

#tg-gallery .tg-tab-num {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    transform: translateY(-8px);
    color: inherit;
    opacity: 0.65;
}

/* Dual-label roll-up on hover */
#tg-gallery .tg-tab-text {
    display: block;
    position: relative;
    overflow: hidden;
    height: 1.05em;
    font-size: clamp(19px, 2.6vw, 30px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

#tg-gallery .tg-tab-text span {
    display: block;
    transition: transform 0.45s cubic-bezier(0.76, 0, 0.24, 1);
}

#tg-gallery .tg-tab:hover .tg-tab-text span,
#tg-gallery .tg-tab:focus-visible .tg-tab-text span {
    transform: translateY(-100%);
}

#tg-gallery .tg-tab-count {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    transform: translateY(-8px);
    min-width: 2ch;
    opacity: 0.65;
}

#tg-gallery .tg-tab.is-active { color: var(--tg-ink); }

#tg-gallery .tg-tab:focus-visible {
    outline: 2px solid var(--tg-ink);
    outline-offset: -2px;
}

/* Sliding ink bar under the active tab (positioned by JS) */
#tg-gallery .tg-tab-ink {
    position: absolute;
    bottom: -1px;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--tg-ink);
    transition: transform 0.55s cubic-bezier(0.76, 0, 0.24, 1),
                width 0.55s cubic-bezier(0.76, 0, 0.24, 1);
}

/* ================= PANELS ================= */

#tg-gallery .tg-panel { display: none; }

#tg-gallery .tg-panel.is-active {
    display: block;
    animation: tg-panel-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tg-panel-in {
    from { opacity: 0; transform: translateY(22px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ================= GALLERY (3D torus engine — layout kept intact) ================= */

#tg-gallery .gallery-instance-wrapper {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch;
    width: 100%;
    margin: 0 auto;
    background: var(--tg-paper);
    overflow-x: hidden;
    box-sizing: border-box;
    gap: clamp(16px, 2.5vw, 32px);
}

#tg-gallery .gallery-container {
    position: relative;
    flex: 1;
    width: 60%;
    height: 62vh;
    min-height: 420px;
    background: var(--tg-paper);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    perspective: 1000px;
    border: 1px solid var(--tg-ink);
    border-radius: 0;

    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    cursor: grab;
}

/* Soft white vignette so the wall fades at the frame edges */
#tg-gallery .gallery-container::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    background:
        linear-gradient(to right, rgba(255,255,255,0.9), rgba(255,255,255,0) 12%, rgba(255,255,255,0) 88%, rgba(255,255,255,0.9)),
        linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(255,255,255,0) 14%, rgba(255,255,255,0) 86%, rgba(255,255,255,0.9));
}

#tg-gallery .white-wall-scene,
#tg-gallery .white-wall {
    position: relative;
    transform-style: preserve-3d;
}

#tg-gallery .ww-item {
    position: absolute;
    width: 300px;
    height: 220px;
    top: -110px;
    left: -150px;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    border: 6px solid var(--tg-paper);
    background: var(--tg-paper);
    box-sizing: border-box;
    transition: border-radius 0.3s ease;
}

#tg-gallery .ww-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    border-radius: 0;
    transition: border-radius 0.3s ease, filter 0.4s ease;
}

#tg-gallery .ww-item.active {
    border-radius: 40px;
    z-index: 10;
}
#tg-gallery .ww-item.active img {
    border-radius: 30px;
}

/* Corner tag inside the frame */
#tg-gallery .tg-container-tag {
    position: absolute;
    left: 14px;
    bottom: 12px;
    z-index: 6;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--tg-gray);
    pointer-events: none;
}

/* ================= INTRO HINT OVERLAY ================= */

#tg-gallery .tg-hint {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.86);
    -webkit-backdrop-filter: blur(7px);
    backdrop-filter: blur(7px);
    opacity: 1;
    transition: opacity 0.6s ease;
}

#tg-gallery .tg-hint.is-hidden {
    opacity: 0;
    pointer-events: none;
}

#tg-gallery .tg-hint-card {
    text-align: center;
    padding: 24px;
    max-width: 380px;
    animation: tg-hint-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tg-hint-in {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 3-axis gyroscope diagram */
#tg-gallery .tg-hint-gyro {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 22px;
    transform-style: preserve-3d;
    perspective: 500px;
}

#tg-gallery .tg-gyro-ring {
    position: absolute;
    inset: 0;
    border: 1.5px dashed var(--tg-ink);
    border-radius: 50%;
}

#tg-gallery .tg-gyro-x {
    animation: tg-gyro-x 5s linear infinite;
}
#tg-gallery .tg-gyro-y {
    animation: tg-gyro-y 7s linear infinite;
}

@keyframes tg-gyro-x {
    from { transform: rotateX(72deg) rotateZ(0deg); }
    to   { transform: rotateX(72deg) rotateZ(360deg); }
}
@keyframes tg-gyro-y {
    from { transform: rotateY(72deg) rotateZ(0deg); }
    to   { transform: rotateY(72deg) rotateZ(-360deg); }
}

#tg-gallery .tg-gyro-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: var(--tg-ink);
    animation: tg-gyro-dot 3.2s ease-in-out infinite;
}

@keyframes tg-gyro-dot {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(26px, -14px); }
    50%  { transform: translate(0, 16px); }
    75%  { transform: translate(-26px, -10px); }
    100% { transform: translate(0, 0); }
}

#tg-gallery .tg-hint-title {
    margin: 0 0 10px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--tg-ink);
}

#tg-gallery .tg-hint-copy {
    margin: 0 0 22px;
    font-size: 13.5px;
    line-height: 1.65;
    color: #4a4a4a;
}
#tg-gallery .tg-hint-copy em { font-style: italic; }

#tg-gallery .tg-hint-btn {
    display: inline-block;
    padding: 13px 30px;
    background: var(--tg-ink);
    color: var(--tg-paper);
    border: 1px solid var(--tg-ink);
    font-family: var(--tg-font);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease;
}

#tg-gallery .tg-hint-btn:hover {
    background: var(--tg-paper);
    color: var(--tg-ink);
}

/* ================= PREVIEW WIDGET ================= */

#tg-gallery .selection-widget {
    width: 35%;
    max-width: 480px;
    padding: 0;
    background: var(--tg-paper);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

#tg-gallery .tg-preview-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 2px 2px 12px;
}

#tg-gallery .tg-preview-head h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--tg-ink);
}

#tg-gallery .tg-preview-counter {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--tg-gray);
    font-variant-numeric: tabular-nums;
}

#tg-gallery .selected-image-container {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--tg-ink);
    border-radius: 0;
    overflow: hidden;
    background: #f4f4f4;
    cursor: pointer;
}

#tg-gallery .selected-image-container img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Blocks the browser's hover/long-press image tools
       (visual search, lens, save menu) on the preview */
    pointer-events: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#tg-gallery .tg-preview-ghost { z-index: 1; }
#tg-gallery .active-image-display { z-index: 2; }

/* Crossfade + settle whenever a new photo lands in focus */
#tg-gallery .selected-image-container.is-fading .active-image-display {
    animation: tg-preview-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes tg-preview-in {
    from { opacity: 0; transform: scale(1.045); }
    to   { opacity: 1; transform: scale(1); }
}

#tg-gallery .expand-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    width: auto;
    height: auto;
    background: rgba(10, 10, 10, 0.85);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-family: var(--tg-font);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease;
}

#tg-gallery .expand-btn:hover {
    background: #000;
    transform: translateY(-2px);
}

#tg-gallery .tg-preview-caption {
    margin: 14px 2px 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--tg-ink);
    min-height: 1.4em;
}

#tg-gallery .tg-preview-note {
    margin: 6px 2px 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--tg-gray);
}

/* ================= FULLSCREEN MODAL (injected by JS, lives on body) ================= */

.tg-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 6, 6, 0.96);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.tg-modal.open {
    display: flex;
    animation: tg-modal-in 0.35s ease both;
}

@keyframes tg-modal-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.tg-modal-figure {
    margin: 0;
    max-width: 92%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.tg-modal-image {
    max-width: 100%;
    max-height: 82vh;
    object-fit: contain;
    border: 1px solid rgba(255, 255, 255, 0.25);
    animation: tg-modal-img 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    pointer-events: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@keyframes tg-modal-img {
    from { opacity: 0; transform: scale(0.96); }
    to   { opacity: 1; transform: scale(1); }
}

.tg-modal-caption {
    color: rgba(255, 255, 255, 0.75);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.tg-modal-close {
    position: absolute;
    top: 22px;
    right: 26px;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    color: #fff;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease;
    z-index: 100000;
}

.tg-modal-close:hover {
    background: #fff;
    color: #000;
}

/* ================= CUSTOM CURSOR (injected by JS, lives on body) ================= */

.tg-cursor {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tg-cursor.is-on { opacity: 1; }

.tg-cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    width: 7px;
    height: 7px;
    margin: -3.5px 0 0 -3.5px;
    border-radius: 50%;
    background: #0a0a0a;
}

.tg-cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 38px;
    height: 38px;
    margin: -19px 0 0 -19px;
    border: 1.5px solid #0a0a0a;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1),
                height 0.3s cubic-bezier(0.22, 1, 0.36, 1),
                margin 0.3s cubic-bezier(0.22, 1, 0.36, 1),
                background 0.3s ease;
}

.tg-cursor-label {
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

/* Ring grows and fills black when hovering something interactive */
.tg-cursor.has-label .tg-cursor-ring {
    width: 68px;
    height: 68px;
    margin: -34px 0 0 -34px;
    background: #0a0a0a;
}

.tg-cursor.has-label .tg-cursor-label { opacity: 1; }

.tg-cursor.is-down .tg-cursor-ring {
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
}

.tg-cursor.is-down.has-label .tg-cursor-ring {
    width: 58px;
    height: 58px;
    margin: -29px 0 0 -29px;
}

/* ================= MOBILE ================= */

@media (max-width: 900px) {
    #tg-gallery .gallery-instance-wrapper {
        flex-direction: column;
    }
    #tg-gallery .gallery-container {
        /* flex:1 comes from the desktop row layout; in the stacked column
           layout it collapses the height, so reset it here */
        flex: none;
        width: 100%;
        height: 56vh;
        min-height: 380px;
    }
    /* Note: the wall's zoom level is set responsively by JS (fitScene)
       so the torus always fills the frame on narrow screens. */
    #tg-gallery .selection-widget {
        width: 100%;
        max-width: 100%;
        margin-top: 22px;
    }
    #tg-gallery .tg-head-row { align-items: center; flex-wrap: wrap; }
    #tg-gallery .tg-tab { padding: 16px 2px 14px; }
    #tg-gallery .tg-hint-card { max-width: 300px; }
    #tg-gallery .tg-hint-copy { font-size: 12.5px; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    #tg-gallery .tg-ticker-track,
    #tg-gallery .tg-gyro-x,
    #tg-gallery .tg-gyro-y,
    #tg-gallery .tg-gyro-dot { animation: none; }
}