/* ═══════════════════════════════════════════════════════════
   gallery.css — Gallery page styles for Little Turtlery
   Requires: public-layout.css (tokens, reset, nav, footer)
   ═══════════════════════════════════════════════════════════ */

/* ─── Hero ───────────────────────────────────────────────── */
.gl-hero {
    background: var(--lt-cream);
    padding-top: calc(var(--nav-h) + var(--sp-3xl));
    padding-bottom: var(--sp-2xl);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Subtle radial decoration behind title */
.gl-hero::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 560px;
    height: 560px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--lt-sage-light) 0%, transparent 68%);
    pointer-events: none;
}

.gl-hero__inner {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin-inline: auto;
}

.gl-hero__title {
    font-size: clamp(40px, 5vw, 56px);
    font-weight: var(--fw-semibold);
    color: var(--lt-ink);
    line-height: 1.15;
    text-wrap: balance;
    max-width: 20ch;
    margin-inline: auto;
    margin-bottom: var(--sp-md);
}

.gl-hero__intro {
    font-size: 15px;
    color: var(--lt-text-soft);
    font-weight: var(--fw-light);
    line-height: 1.85;
    max-width: 440px;
    margin-inline: auto;
    margin-bottom: var(--sp-xl);
}

/* Stats row */
.gl-hero__stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-xl);
    flex-wrap: wrap;
}

.gl-hero__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.gl-hero__stat-num {
    font-size: 26px;
    font-weight: var(--fw-semibold);
    color: var(--lt-sage-dark);
    line-height: 1;
    letter-spacing: -.01em;
}

.gl-hero__stat-label {
    font-size: 12px;
    font-weight: var(--fw-medium);
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--lt-text-muted);
}

.gl-hero__stat-divider {
    width: 1px;
    height: 32px;
    background: var(--lt-border);
    flex-shrink: 0;
}

/* ─── Category Entry Cards ───────────────────────────────── */
.gl-categories {
    background: var(--lt-white);
    padding-block: var(--sp-2xl);
}

.gl-categories__label {
    text-align: center;
    margin-bottom: var(--sp-xl);
}

.gl-categories__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-md);
}

/* Each category card: tall portrait proportions */
.gl-cat-card {
    position: relative;
    border-radius: var(--r-lg);
    overflow: hidden;
    aspect-ratio: 3 / 4;
    display: flex;
    align-items: flex-end;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--ease), box-shadow var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.gl-cat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.gl-cat-card__bg {
    position: absolute;
    inset: 0;
    transition: transform .55s ease;
}

.gl-cat-card:hover .gl-cat-card__bg {
    transform: scale(1.06);
}

/* Two-layer gradient overlay: dark at bottom for legibility + subtle top tint */
.gl-cat-card__overlay {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to top,
            rgba(0,0,0,.72) 0%,
            rgba(0,0,0,.18) 55%,
            rgba(0,0,0,0)   100%);
}

.gl-cat-card__body {
    position: relative;
    z-index: 1;
    padding: 20px;
    width: 100%;
}

.gl-cat-card__icon {
    display: block;
    font-size: 26px;
    margin-bottom: 8px;
    line-height: 1;
}

.gl-cat-card__title {
    font-size: clamp(16px, 1.6vw, 20px);
    font-weight: var(--fw-semibold);
    color: #fff;
    line-height: 1.25;
    margin-bottom: 4px;
}

.gl-cat-card__sub {
    font-size: 12px;
    color: rgba(255,255,255,.72);
    font-weight: var(--fw-light);
    line-height: 1.55;
    margin: 0;
}

/* ─── Browse: Filter + Grid ──────────────────────────────── */
.gl-browse {
    background: var(--lt-cream);
}

/* ─── Filter block — wraps segment control + pill panels ─── */
.gl-filter-block {
    margin-bottom: var(--sp-2xl);
}

/* ─── Segment control: [ รูปทรง | ชนิดหิน ] ─────────────── */
.gl-filter__segment {
    display: flex;
    background: var(--lt-stone-xlight);
    border: 1px solid var(--lt-border-light);
    border-radius: var(--r-full);
    padding: 3px;
    width: fit-content;
    margin-bottom: var(--sp-md);
}

.gl-filter__seg-btn {
    padding: 7px 22px;
    border-radius: var(--r-full);
    border: none;
    background: transparent;
    font-family: var(--font);
    font-size: 13px;
    font-weight: var(--fw-medium);
    color: var(--lt-text-muted);
    cursor: pointer;
    transition: background var(--ease), color var(--ease);
    white-space: nowrap;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.gl-filter__seg-btn.is-active {
    background: var(--lt-ink);
    color: #fff;
}

.gl-filter__seg-btn:hover:not(.is-active) {
    color: var(--lt-ink);
}

/* ─── Filter panel — horizontal scroll pill strip ─────────── */
.gl-filter {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px; /* prevent clipping pill borders on scroll */
}

/* Remove double margin when filter is inside filter-block */
.gl-filter-block .gl-filter {
    margin-bottom: 0;
}

/* Hidden panel (toggled by JS) */
.gl-filter.is-hidden {
    display: none;
}

.gl-filter::-webkit-scrollbar {
    display: none;
}

.gl-filter__pills {
    display: flex;
    gap: var(--sp-sm);
    min-width: max-content;
    padding-inline: 2px; /* breathing room at edges */
}

.gl-filter__pill {
    flex-shrink: 0;
    padding: 8px 18px;            /* slightly more compact than 9/20 */
    border-radius: var(--r-full);
    border: 1.5px solid var(--lt-border);
    background: var(--lt-white);
    font-family: var(--font);
    font-size: 13px;
    font-weight: var(--fw-medium);
    color: var(--lt-text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--ease), border-color var(--ease), color var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.gl-filter__pill:hover {
    border-color: var(--lt-sage);
    color: var(--lt-sage-dark);
    background: var(--lt-sage-light);
}

.gl-filter__pill.is-active {
    background: var(--lt-sage);
    border-color: var(--lt-sage);
    color: #fff;
}

.gl-filter__pill.is-active:hover {
    background: var(--lt-sage-dark);
    border-color: var(--lt-sage-dark);
    color: #fff;
}

/* ─── Gallery Grid ───────────────────────────────────────── */
.gl-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-lg);
}

/* Item visibility — toggled by JS filter */
.gl-item.is-hidden {
    display: none;
}

/* Item card shell */
.gl-item__link {
    display: block;
    background: var(--lt-white);
    border: 1px solid var(--lt-border);
    border-radius: var(--r-md);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.gl-item__link:hover {
    border-color: var(--lt-sage);
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

/* Portrait image frame — 4:5 ratio fits Instagram-style assets naturally */
.gl-item__frame {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: var(--lt-sage-xlight);
}

/* Real image — sits above placeholder, z-index 1 */
.gl-item__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: 1;
    transition: transform .55s ease;
    display: block;
}

.gl-item__link:hover .gl-item__img {
    transform: scale(1.04);
}

/* Gradient placeholder — shown when no image / image fails */
.gl-item__placeholder {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gl-item__placeholder-icon {
    font-size: 38px;
    opacity: .45;
    user-select: none;
}

/* When image load fails, hide the broken img tag */
.gl-item__frame.no-img .gl-item__img {
    display: none;
}

/* Badge — top-right corner of frame */
.gl-item__badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    font-size: 10px;
    font-weight: var(--fw-semibold);
    letter-spacing: .12em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: var(--r-full);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.gl-item__badge--featured {
    background: rgba(255,255,255,.88);
    color: var(--lt-sage-dark);
}

.gl-item__badge--rare {
    background: rgba(255,255,255,.88);
    color: var(--lt-stone-dark);
}

.gl-item__badge--archive {
    background: rgba(255,255,255,.72);
    color: var(--lt-text-muted);
}

/* Card text body */
.gl-item__body {
    padding: 16px 18px 20px;    /* more generous: consistent with system sp-md */
}

.gl-item__stone {
    display: block;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--lt-sage-dark);
    margin-bottom: 5px;
}

.gl-item__title {
    font-size: 15px;
    font-weight: var(--fw-medium);
    color: var(--lt-ink);
    line-height: 1.35;
    margin-bottom: 4px;
}

.gl-item__sub {
    font-size: 13px;
    color: var(--lt-text-muted);
    font-weight: var(--fw-light);
    line-height: 1.6;
    margin: 0;
}

/* Empty state */
.gl-empty {
    text-align: center;
    padding: 64px 0 32px;
    color: var(--lt-text-muted);
    font-size: 14px;
}

.gl-empty span {
    display: block;
    font-size: 40px;
    margin-bottom: 12px;
}

/* ─── Editorial Break ────────────────────────────────────── */
.gl-editorial {
    background: var(--lt-sage-light);
    padding-block: var(--sp-3xl);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Subtle large decorative character */
.gl-editorial::before {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 320px;
    color: var(--lt-sage);
    opacity: .07;
    pointer-events: none;
    user-select: none;
    line-height: 1;
}

.gl-editorial__inner {
    position: relative;
    z-index: 1;
    max-width: 520px;
    margin-inline: auto;
}

.gl-editorial__rule {
    width: 32px;
    height: 1.5px;
    background: var(--lt-sage);
    margin: 0 auto var(--sp-lg);
}

.gl-editorial__title {
    font-size: clamp(24px, 3.5vw, 38px);
    font-weight: var(--fw-semibold);
    color: var(--lt-ink);
    line-height: 1.25;
    white-space: pre-line;
    margin-bottom: var(--sp-lg);
}

.gl-editorial__body {
    font-size: 15px;
    color: var(--lt-text-soft);
    font-weight: var(--fw-light);
    line-height: 1.9;
}

/* ─── Closing CTA ────────────────────────────────────────── */
.gl-cta {
    background: var(--lt-white);
    padding-block: var(--sp-3xl);
    text-align: center;
}

.gl-cta__title {
    font-size: clamp(22px, 3vw, 34px);
    font-weight: var(--fw-semibold);
    color: var(--lt-ink);
    line-height: 1.3;
    margin-bottom: var(--sp-md);
}

.gl-cta__body {
    font-size: 15px;
    color: var(--lt-text-soft);
    font-weight: var(--fw-light);
    line-height: 1.85;
    max-width: 440px;
    margin-inline: auto;
    margin-bottom: var(--sp-xl);
}

.gl-cta__actions {
    display: flex;
    gap: var(--sp-md);
    justify-content: center;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════
   SHOW PAGE  (gs- prefix — Gallery Show)
   ═══════════════════════════════════════════════════════════ */

/* ─── Stone Header ───────────────────────────────────────── */
.gs-header {
    background: var(--lt-stone-xlight);
    padding-top: calc(var(--nav-h) + var(--sp-2xl));
    padding-bottom: var(--sp-2xl);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Stone-palette gradient wash — very subtle, just a whisper of colour */
.gs-header__gradient-wash {
    position: absolute;
    inset: 0;
    opacity: .05;
    pointer-events: none;
}

/* Back link — top-left, above the title block */
.gs-header__back {
    position: absolute;
    top: calc(var(--nav-h) + var(--sp-lg));
    left: clamp(16px, 4vw, 40px);
    font-size: 13px;
    font-weight: var(--fw-medium);
    color: var(--lt-text-muted);
    text-decoration: none;
    letter-spacing: .01em;
    transition: color var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    z-index: 2;
}

.gs-header__back:hover { color: var(--lt-sage-dark); }

.gs-header__inner {
    position: relative;
    z-index: 1;
    max-width: 640px;
    margin-inline: auto;
}

/* Stone-type label pill */
.gs-header__stone-label {
    display: inline-block;
    background: var(--lt-sage-light);
    color: var(--lt-sage-dark);
    font-size: 11px;
    font-weight: var(--fw-semibold);
    letter-spacing: .16em;
    text-transform: uppercase;
    padding: 4px 16px;
    border-radius: var(--r-full);
    margin-bottom: var(--sp-lg);
}

.gs-header__title {
    font-size: clamp(28px, 4.5vw, 52px);
    font-weight: var(--fw-semibold);
    color: var(--lt-ink);
    line-height: 1.15;
    margin-bottom: var(--sp-sm);
}

/* Thai subtitle — italic, reads as a poetic caption */
.gs-header__subtitle {
    font-size: clamp(15px, 1.6vw, 18px);
    color: var(--lt-text-soft);
    font-weight: var(--fw-light);
    font-style: italic;
    line-height: 1.7;
    max-width: 480px;
    margin-inline: auto;
    margin-bottom: var(--sp-md);
}

/* Form badge — small allcaps, sits below subtitle */
.gs-header__form-badge {
    font-size: 12px;
    font-weight: var(--fw-medium);
    color: var(--lt-stone-dark);
    letter-spacing: .12em;
    text-transform: uppercase;
}

/* ─── Main: Cover + Info sidebar ─────────────────────────── */
.gs-main {
    background: var(--lt-white);
}

/* 55/45 split — image gets more room, info sidebar breathes */
.gs-main__grid {
    display: grid;
    grid-template-columns: 55fr 45fr;
    gap: clamp(40px, 6vw, 88px);
    align-items: start;
}

/* Cover image — sticky so it stays visible while scrolling info */
.gs-cover {
    position: sticky;
    top: calc(var(--nav-h) + var(--sp-xl));
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.gs-cover__img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    object-position: center;
}

/* Gradient placeholder when no image available */
.gs-cover__placeholder {
    aspect-ratio: 4 / 5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    opacity: .35;
}

/* Info sidebar — stacked sections */
.gs-info {
    display: flex;
    flex-direction: column;
    gap: var(--sp-xl);
    padding-block: var(--sp-md);
}

/* Metadata table — stone / form */
.gs-info__meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid var(--lt-border-light);
    border-bottom: 1px solid var(--lt-border-light);
    padding-block: var(--sp-md);
}

.gs-info__meta-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-md);
}

.gs-info__meta-label {
    font-size: 11px;
    font-weight: var(--fw-semibold);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--lt-text-muted);
    flex-shrink: 0;
}

.gs-info__meta-val {
    font-size: 14px;
    font-weight: var(--fw-medium);
    color: var(--lt-ink);
    text-align: right;
}

/* Description block */
.gs-info__desc {
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
}

/* Thai lead line — the primary description, reads naturally in Thai UI */
.gs-info__desc-lead {
    font-size: clamp(16px, 1.8vw, 19px);
    font-weight: var(--fw-semibold);
    color: var(--lt-ink);
    line-height: 1.55;
    margin: 0;
}

/* English description — secondary, pull-quote style, muted */
.gs-info__desc-en {
    font-size: 14px;
    color: var(--lt-text-soft);
    font-weight: var(--fw-light);
    line-height: 1.95;
    font-style: italic;
    border-left: 2px solid var(--lt-stone);
    padding-left: 18px;
    margin: 0;
}

/* Action buttons */
.gs-info__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gs-info__actions .lt-btn {
    width: 100%;
    justify-content: center;
}

/* ─── Additional photos ──────────────────────────────────── */
.gs-photos {
    background: var(--lt-cream);
    padding-block: var(--sp-2xl);
}

/* Auto-fill columns — fills width naturally for 1, 2, or 3 extra images */
.gs-photos__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-md);
}

.gs-photos__frame {
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.gs-photos__img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
    transition: transform .55s ease;
}

.gs-photos__frame:hover .gs-photos__img {
    transform: scale(1.03);
}

/* ─── Related stones ─────────────────────────────────────── */
.gs-related {
    background: var(--lt-stone-xlight);
}

.gs-related__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-md);
}

.gs-related-card {
    display: block;
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--lt-border-light);
    text-decoration: none;
    color: inherit;
    background: var(--lt-white);
    transition: box-shadow var(--ease), transform var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.gs-related-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px);
}

/* Portrait frame — same 4:5 ratio as main grid items */
.gs-related-card__frame {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
}

/* Gradient background — always rendered at z-index 0 */
.gs-related-card__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gs-related-card__icon {
    font-size: 40px;
    opacity: .28;
    user-select: none;
    pointer-events: none;
}

/* Real image — sits above gradient at z-index 1 */
.gs-related-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: 1;
    transition: transform .55s ease;
}

.gs-related-card:hover .gs-related-card__img {
    transform: scale(1.04);
}

.gs-related-card__body {
    padding: 12px 14px 16px;
}

.gs-related-card__stone {
    display: block;
    font-size: 11px;
    font-weight: var(--fw-semibold);
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--lt-sage-dark);
    margin-bottom: 4px;
}

.gs-related-card__title {
    font-size: 14px;
    font-weight: var(--fw-medium);
    color: var(--lt-ink);
    line-height: 1.35;
    margin: 0 0 3px;
}

.gs-related-card__sub {
    font-size: 12px;
    color: var(--lt-text-muted);
    font-weight: var(--fw-light);
    line-height: 1.5;
    margin: 0;
}

/* ─── Responsive — show page ─────────────────────────────── */
@media (max-width: 900px) {
    /* Stack cover + info vertically */
    .gs-main__grid {
        grid-template-columns: 1fr;
    }

    /* Unpin the sticky cover — no longer needed when stacked */
    .gs-cover {
        position: static;
        max-width: 480px;
        margin-inline: auto;
    }

    /* Info sidebar full-width actions */
    .gs-info__actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .gs-info__actions .lt-btn {
        width: auto;
        flex: 1;
        min-width: 140px;
    }

    .gs-related__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .gs-header {
        padding-top: calc(var(--nav-h) + var(--sp-xl));
    }

    .gs-header__back {
        top: calc(var(--nav-h) + var(--sp-sm));
        font-size: 12px;
    }

    /* Photos: single column on mobile (images are tall, 2-col would be tiny) */
    .gs-photos__grid {
        grid-template-columns: 1fr;
        max-width: 480px;
        margin-inline: auto;
    }

    .gs-related__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--sp-sm);
    }

    .gs-info__actions {
        flex-direction: column;
    }

    .gs-info__actions .lt-btn {
        width: 100%;
    }
}

/* ─── Responsive — index page ────────────────────────────── */
@media (max-width: 960px) {
    .gl-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .gl-hero {
        padding-top: calc(var(--nav-h) + var(--sp-2xl));
    }

    .gl-hero__stats {
        gap: var(--sp-lg);
    }

    .gl-hero__stat-divider {
        height: 24px;
    }

    /* Tighter segment on small screens */
    .gl-filter__seg-btn {
        padding: 7px 16px;
        font-size: 12px;
    }

    .gl-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--sp-sm);
    }

    .gl-item__body {
        padding: 12px 14px 15px;
    }

    .gl-item__title {
        font-size: 13px;
    }

    .gl-item__sub {
        display: none; /* keep cards lean on mobile */
    }

    .gl-cta__actions {
        flex-direction: column;
        align-items: center;
    }
}
