/* ═══ Shared card photos — trigger affordance + full-screen viewer ═══════════
   Used by the card detail page, the shop grid/list, and the Operations grid.
   The photo itself is never transformed on hover; hovering only reveals actions. */

:root {
    /* The native zoom-in cursor is a low-resolution bitmap that looks rough on
       high-DPI screens. This is the same magnifier drawn as vector art: a dark halo
       under white strokes so it reads on any photo, hotspot at the lens centre.
       Falls back to the native cursor if data-URI cursors are unavailable. */
    --cp-cursor-zoom: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg fill='none' stroke-linecap='round'%3E%3Cg stroke='%230b1526' stroke-width='5'%3E%3Ccircle cx='16' cy='16' r='10'/%3E%3Cpath d='M23.8 23.8 33 33'/%3E%3Cpath d='M11.5 16h9M16 11.5v9'/%3E%3C/g%3E%3Cg stroke='%23ffffff' stroke-width='2.4'%3E%3Ccircle cx='16' cy='16' r='10'/%3E%3Cpath d='M23.8 23.8 33 33'/%3E%3Cpath d='M11.5 16h9M16 11.5v9'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") 16 16, zoom-in;

    /* Matching vector hands. Open palm invites the drag; the fist confirms the grab.
       Same dark-halo-under-white treatment, hotspot at the centre of the palm. */
    --cp-cursor-grab: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg stroke='%230b1526' fill='none' stroke-linecap='round'%3E%3Cg stroke-width='14.7'%3E%3Cpath d='M16 26.5 26 26.5'/%3E%3C/g%3E%3Cg stroke-width='6.4'%3E%3Cpath d='M14.5 12.5 14.5 24'/%3E%3Cpath d='M19.5 10 19.5 24'/%3E%3Cpath d='M24.5 11.5 24.5 24'/%3E%3Cpath d='M29 14.5 29 24'/%3E%3Cpath d='M10 20 13.5 25'/%3E%3C/g%3E%3C/g%3E%3Cg stroke='%23ffffff' fill='none' stroke-linecap='round'%3E%3Cg stroke-width='11.5'%3E%3Cpath d='M16 26.5 26 26.5'/%3E%3C/g%3E%3Cg stroke-width='3.8'%3E%3Cpath d='M14.5 12.5 14.5 24'/%3E%3Cpath d='M19.5 10 19.5 24'/%3E%3Cpath d='M24.5 11.5 24.5 24'/%3E%3Cpath d='M29 14.5 29 24'/%3E%3Cpath d='M10 20 13.5 25'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") 20 20, grab;
    --cp-cursor-grabbing: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cg stroke='%230b1526' fill='none' stroke-linecap='round'%3E%3Cg stroke-width='13.7'%3E%3Cpath d='M16 28 26 28'/%3E%3C/g%3E%3Cg stroke-width='6.4'%3E%3Cpath d='M14.5 18 14.5 23'/%3E%3Cpath d='M19.5 16.5 19.5 23'/%3E%3Cpath d='M24.5 17 24.5 23'/%3E%3Cpath d='M28.8 18.5 28.8 23'/%3E%3Cpath d='M11 25 16 22.5'/%3E%3C/g%3E%3C/g%3E%3Cg stroke='%23ffffff' fill='none' stroke-linecap='round'%3E%3Cg stroke-width='10.5'%3E%3Cpath d='M16 28 26 28'/%3E%3C/g%3E%3Cg stroke-width='3.8'%3E%3Cpath d='M14.5 18 14.5 23'/%3E%3Cpath d='M19.5 16.5 19.5 23'/%3E%3Cpath d='M24.5 17 24.5 23'/%3E%3Cpath d='M28.8 18.5 28.8 23'/%3E%3Cpath d='M11 25 16 22.5'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") 20 20, grabbing;
}

/* ── Trigger: any photo that opens the viewer ── */
.cp-trigger { position: relative; display: block; cursor: var(--cp-cursor-zoom); }
.cp-trigger img { display: block; }
.cp-noimg { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font-size: 2rem; }

/* Scrim + actions, revealed on hover or keyboard focus. No magnification. */
.cp-trigger-overlay {
    position: absolute; inset: 0; z-index: 2;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    opacity: 0;
    background: linear-gradient(180deg, rgba(6,12,26,.05), rgba(6,12,26,.55));
    transition: opacity .18s ease;
    pointer-events: none;
}
.cp-trigger:hover .cp-trigger-overlay,
.cp-trigger:focus-visible .cp-trigger-overlay { opacity: 1; }
.cp-trigger:focus-visible { outline: 2px solid var(--rule-dark, #94a3b8); outline-offset: 2px; }

.cp-action {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 14px; border-radius: 999px;
    background: rgba(247, 249, 251, .94);
    color: #07152c; font-size: .78rem; font-weight: 900;
    box-shadow: 0 6px 18px rgba(0,0,0,.3);
    transform: translateY(6px);
    transition: transform .18s ease;
}
.cp-trigger:hover .cp-action,
.cp-trigger:focus-visible .cp-action { transform: translateY(0); }
.cp-action i { font-size: .8rem; }

/* Persistent photo-count chip (visible without hover). */
.cp-count-chip {
    position: absolute; right: 7px; bottom: 7px; z-index: 3;
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 8px; border-radius: 999px;
    background: rgba(8,15,32,.78); color: #f2f5f8;
    font-size: .68rem; font-weight: 800;
    pointer-events: none;
}
.cp-count-chip i { font-size: .64rem; }

/* Touch devices have no hover: keep the photo clean, chip still shows. */
@media (hover: none) {
    .cp-trigger-overlay { display: none; }
}

/* ═══ Viewer ═══════════════════════════════════════════════════════════════ */
body.cardphotos-locked { overflow: hidden; }
.cardphotos {
    position: fixed; inset: 0; z-index: 260000;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: rgba(6, 12, 26, .82);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    animation: cardphotosIn .16s ease-out;
}
.cardphotos[hidden] { display: none !important; }
@keyframes cardphotosIn { from { opacity: 0; } to { opacity: 1; } }

.cardphotos-panel {
    display: flex; flex-direction: column;
    width: min(1040px, 100%); max-height: min(92vh, 900px);
    overflow: hidden;
    border: 1px solid var(--rule); border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 40px 90px rgba(0,0,0,.55);
}
.cardphotos-head {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px 14px 20px;
    border-bottom: 1px solid var(--rule);
}
.cardphotos-title {
    flex: 1; min-width: 0; margin: 0;
    color: var(--ink); font-size: 1rem; font-weight: 900; letter-spacing: -.01em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cardphotos-x {
    flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center;
    border: 1px solid var(--rule); border-radius: 10px;
    background: var(--photo-well); color: var(--ink);
    font-size: 1rem; cursor: pointer; transition: background .15s, transform .15s;
}
.cardphotos-x:hover { background: var(--rule); transform: rotate(90deg); }

.cardphotos-stage {
    position: relative;
    flex: 1; min-height: 0;
    display: flex; align-items: stretch; justify-content: center; gap: 12px;
    padding: 18px 18px 64px;
    background: var(--photo-well);
}
/* The frame is the zoom viewport; the image is sized to fit then transformed. */
.cardphotos-frame {
    position: relative;
    flex: 1; min-width: 0; min-height: 0;
    display: grid; place-items: center;
    overflow: hidden; border-radius: 10px;
    touch-action: none;
    /* Default arrow in the letterboxed area — the magnifier belongs on the photo only. */
    cursor: default;
}
.cardphotos-frame .cardphotos-img { cursor: var(--cp-cursor-zoom); }
.cardphotos-frame.is-zoomed .cardphotos-img { cursor: var(--cp-cursor-grab); }
/* While dragging, pointer capture can carry the cursor off the photo, so hold
   the grabbing cursor across the whole frame until the drag ends. */
.cardphotos-frame.is-grabbing,
.cardphotos-frame.is-grabbing .cardphotos-img { cursor: var(--cp-cursor-grabbing); }
.cardphotos-img {
    display: block;
    max-width: none; max-height: none;
    transform-origin: center center;
    will-change: transform;
    -webkit-user-select: none; user-select: none;
    -webkit-user-drag: none;
}
.cardphotos-busy {
    position: absolute; inset: 0; z-index: 4;
    display: grid; place-items: center;
    color: var(--muted); font-size: .85rem; font-weight: 800;
}
.cardphotos-busy[hidden] { display: none !important; }

.cardphotos-nav {
    flex: 0 0 auto; align-self: center;
    width: 44px; height: 36px; padding: 0;
    border: 0; background: transparent; cursor: pointer;
    transition: transform .15s, filter .15s;
}
.cardphotos-nav svg { width: 100%; height: 100%; display: block; }
.cardphotos-nav.next { transform: scaleX(-1); }
.cardphotos-nav.prev:hover { transform: scale(1.12); filter: brightness(1.1); }
.cardphotos-nav.next:hover { transform: scaleX(-1) scale(1.12); filter: brightness(1.1); }
.cardphotos-nav[hidden] { display: none !important; }

/* Zoom console — floating glass bar over the stage. */
.cardphotos-zoom {
    position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5;
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    border: 1px solid rgba(255,255,255,.16); border-radius: 999px;
    background: rgba(8, 15, 32, .78);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0,0,0,.4);
    color: #eef2f6;
}
.cardphotos-zbtn {
    width: 30px; height: 30px; display: grid; place-items: center;
    border: 1px solid rgba(255,255,255,.18); border-radius: 50%;
    background: rgba(255,255,255,.07); color: #eef2f6;
    font-size: .74rem; cursor: pointer; transition: background .15s, transform .15s;
}
.cardphotos-zbtn:hover { background: rgba(255,255,255,.18); transform: scale(1.08); }
.cardphotos-range { width: clamp(110px, 22vw, 220px); accent-color: #cfd8e3; cursor: pointer; }
.cardphotos-pct { min-width: 52px; text-align: center; font-size: .82rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.cardphotos-zsep { width: 1px; height: 20px; background: rgba(255,255,255,.2); }
.cardphotos-chip {
    padding: 6px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
    background: rgba(255,255,255,.07); color: #eef2f6;
    font-size: .74rem; font-weight: 800; cursor: pointer; transition: background .15s;
}
.cardphotos-chip:hover { background: rgba(255,255,255,.2); }

.cardphotos-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 12px 20px;
    border-top: 1px solid var(--rule);
}
.cardphotos-thumbs { display: flex; align-items: center; gap: 10px; }
.cardphotos-thumbs[hidden] { display: none !important; }
.cardphotos-thumbs button {
    width: 58px; height: 76px; padding: 4px; overflow: hidden;
    border: 1px solid var(--rule); border-radius: 9px;
    background: var(--photo-well); cursor: pointer;
    opacity: .62; transition: opacity .15s, border-color .15s, transform .15s;
}
.cardphotos-thumbs button img { width: 100%; height: 100%; object-fit: contain; }
.cardphotos-thumbs button:hover { opacity: 1; transform: translateY(-2px); }
.cardphotos-thumbs button.is-active { opacity: 1; border-color: var(--rule-dark); box-shadow: 0 0 0 1px var(--rule-dark); }

.cardphotos-actions { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.cardphotos-hint { color: var(--muted); font-size: .76rem; }
.cardphotos-count { color: var(--muted); font-size: .82rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cardphotos-details {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 999px;
    background: linear-gradient(135deg, #f5f7f8, #aeb8c1 58%, #eef2f5);
    color: #07152c; font-size: .86rem; font-weight: 900; text-decoration: none;
    box-shadow: 0 6px 16px rgba(0,0,0,.2); transition: transform .15s, filter .15s;
}
.cardphotos-details:hover { transform: translateY(-1px); filter: brightness(1.05); }
.cardphotos-details[hidden] { display: none !important; }

@media (max-width: 620px) {
    .cardphotos { padding: 0; }
    .cardphotos-panel { width: 100%; height: 100%; max-height: 100%; border: 0; border-radius: 0; }
    .cardphotos-stage { padding: 10px 10px 58px; gap: 6px; }
    .cardphotos-nav { width: 32px; height: 28px; }
    .cardphotos-thumbs button { width: 46px; height: 60px; }
    .cardphotos-foot { justify-content: center; }
    .cardphotos-actions { width: 100%; justify-content: space-between; margin-left: 0; }
    /* Pinch-to-zoom covers this on touch, so keep only the essentials. */
    .cardphotos-hint { display: none; }
    .cardphotos-zoom { gap: 7px; padding: 6px 10px; bottom: 10px; }
    .cardphotos-range { width: 92px; }
    .cardphotos-zsep { display: none; }
    .cardphotos-chip { padding: 5px 9px; font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
    .cardphotos { animation: none; }
    .cp-trigger-overlay, .cp-action { transition: none; }
}
