/* ============================================================
   STAMP CATALOGUE — Now in catalogue drawer on map page (#p3)
   ============================================================ */

/* --- Cream background on the map tab (hosts the catalogue drawer) --- */
#p3, #tab-map {
    background: var(--paper, #F4F1EA) !important;
    border-color: transparent !important;
    padding: 0 !important;
}

/* --- Page wrapper --- */
.sc-page {
    padding: var(--space-md) var(--space-md) calc(var(--nav-height) + var(--space-xl));
    max-width: 600px;
    margin: 0 auto;
    font-family: var(--font-ui);
}

/* --- Split-flap header --- */
.sc-header {
    text-align: center;
    margin-bottom: var(--space-lg);
    animation: sc-fadeIn 0.5s ease;
}
.sc-header-label {
    font-family: var(--font-ui);
    font-size: 10px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(0,0,0,0.4);
    margin-bottom: var(--space-xs);
}
.sc-header h1 {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--ink);
    margin: 0;
    letter-spacing: 2px;
}
.sc-header h1 span {
    background: var(--gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sc-header-sub {
    font-size: 11px;
    color: rgba(0,0,0,0.5);
    margin-top: var(--space-xs);
}

/* --- Progress ring --- */
.sc-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--surface-card);
    border-radius: var(--radius-md);
    animation: sc-fadeSlideUp 0.5s ease 0.1s both;
}
.sc-progress__ring {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
}
.sc-progress__ring svg {
    transform: rotate(-90deg);
    width: 72px;
    height: 72px;
}
.sc-progress__ring-bg {
    fill: none;
    stroke: rgba(0,0,0,0.08);
    stroke-width: 6;
}
.sc-progress__ring-fill {
    fill: none;
    stroke: var(--accent-gold);
    stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s var(--ease-out);
}
.sc-progress__count {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.sc-progress__earned {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--ink);
    line-height: 1;
}
.sc-progress__total {
    font-size: 10px;
    color: rgba(0,0,0,0.4);
    margin-top: 2px;
}
.sc-progress__breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}
.sc-progress__stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(0,0,0,0.6);
}
.sc-progress__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sc-progress__dot--common { background: rgba(0,0,0,0.2); }
.sc-progress__dot--rare { background: #3498db; }
.sc-progress__dot--epic { background: #9b59b6; }
.sc-progress__dot--legendary { background: #f39c12; }

/* --- Horizontal scroll rows --- */
.sc-row {
    margin-bottom: var(--space-lg);
    animation: sc-fadeSlideUp 0.5s ease 0.2s both;
}
.sc-row-title {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(0,0,0,0.6);
    margin-bottom: var(--space-sm);
    padding-left: var(--space-xs);
}
.sc-row__scroll {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-sm);
    scrollbar-width: none;
}
.sc-row__scroll::-webkit-scrollbar { display: none; }
.sc-row__scroll .sc-stamp {
    scroll-snap-align: start;
    flex-shrink: 0;
    width: 100px;
    height: 100px;
}
.sc-row__empty {
    font-size: 12px;
    color: rgba(0,0,0,0.3);
    padding: var(--space-md);
    text-align: center;
    border: 1px dashed rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
}

/* --- Departing row urgency --- */
.sc-row--departing .sc-row-title {
    color: var(--accent-red);
}
.sc-row--departing .sc-stamp {
    animation: sc-depart-pulse 2s ease-in-out infinite;
}
.sc-row--departing .sc-stamp__countdown {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(231,76,60,0.85);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    z-index: 2;
}

/* --- Arriving row --- */
.sc-row--arriving .sc-row-title {
    color: var(--accent-green);
}
.sc-row--arriving .sc-stamp__countdown {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(39,174,96,0.85);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
    z-index: 2;
}

/* --- Filter pill bar --- */
.sc-filter {
    display: flex;
    gap: var(--space-xs);
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-md);
    animation: sc-fadeSlideUp 0.5s ease 0.3s both;
}
.sc-filter::-webkit-scrollbar { display: none; }
.sc-filter__pill {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(0,0,0,0.15);
    background: transparent;
    color: rgba(0,0,0,0.5);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
    white-space: nowrap;
}
.sc-filter__pill:hover {
    border-color: rgba(0,0,0,0.3);
    color: var(--ink);
}
.sc-filter__pill--active {
    background: rgba(179,135,40,0.12);
    border-color: #b38728;
    color: #b38728;
}

/* --- Stamp counter --- */
.sc-counter {
    font-size: 11px;
    letter-spacing: 1px;
    color: rgba(0,0,0,0.35);
    text-align: center;
    margin-bottom: var(--space-md);
}
.sc-counter em {
    color: #b38728;
    font-style: normal;
    font-weight: 700;
}

/* --- Collection grid --- */
.sc-grid-label {
    font-family: var(--font-display);
    font-size: 13px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: rgba(0,0,0,0.6);
    margin-bottom: var(--space-sm);
    padding-left: var(--space-xs);
}
.sc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    animation: sc-fadeSlideUp 0.5s ease 0.35s both;
}
@media (min-width: 700px) {
    .sc-grid { grid-template-columns: repeat(5, 1fr); }
    .sc-page { max-width: 700px; }
}

/* --- Individual stamp tile --- */
.sc-stamp {
    position: relative;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid rgba(0,0,0,0.08);
    background: var(--surface-card);
    transition: transform var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
.sc-stamp:hover {
    transform: translateY(-2px);
}
.sc-stamp:active {
    transform: scale(0.96);
}

/* Stamp image / video */
.sc-stamp__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: 4px;
}
.sc-stamp__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    background: var(--surface-darker);
    color: rgba(0,0,0,0.15);
}

/* --- Rarity border colours --- */
.sc-stamp--common {
    border-color: rgba(0,0,0,0.1);
}
.sc-stamp--rare {
    border-color: #3498db;
}
.sc-stamp--rare:hover {
    box-shadow: 0 0 12px rgba(52,152,219,0.3);
}
.sc-stamp--epic {
    border-color: #9b59b6;
}
.sc-stamp--epic:hover {
    box-shadow: 0 0 12px rgba(155,89,182,0.3);
}
.sc-stamp--legendary {
    border-color: #f39c12;
    animation: sc-legendary-shimmer 3s ease-in-out infinite;
}
.sc-stamp--legendary:hover {
    box-shadow: 0 0 16px rgba(243,156,18,0.4);
}

/* --- Stamp states --- */
.sc-stamp--locked .sc-stamp__img,
.sc-stamp--locked .sc-stamp__placeholder {
    filter: grayscale(1) brightness(0.3) contrast(0.5);
    opacity: 0.6;
}
.sc-stamp--earned {
    /* Full colour, gets rarity glow on hover */
}
.sc-stamp--earned.sc-stamp--common:hover { box-shadow: 0 0 10px rgba(0,0,0,0.1); }
.sc-stamp--earned.sc-stamp--rare { box-shadow: 0 0 8px rgba(52,152,219,0.2); }
.sc-stamp--earned.sc-stamp--epic { box-shadow: 0 0 8px rgba(155,89,182,0.2); }
.sc-stamp--earned.sc-stamp--legendary { box-shadow: 0 0 10px rgba(243,156,18,0.25); }

.sc-stamp--tracked .sc-stamp__img,
.sc-stamp--tracked .sc-stamp__placeholder {
    filter: grayscale(0.5) brightness(0.5);
    opacity: 0.8;
}

/* --- Stamp overlays --- */
.sc-stamp__badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    border-radius: var(--radius-pill);
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 2;
}
.sc-stamp__badge--common { color: rgba(255,255,255,0.7); }
.sc-stamp__badge--rare { color: #5dade2; }
.sc-stamp__badge--epic { color: #bb8fce; }
.sc-stamp__badge--legendary { color: #f5b041; }

.sc-stamp__check {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.sc-stamp__check svg {
    width: 12px;
    height: 12px;
    stroke: #fff;
    stroke-width: 3;
    fill: none;
}

.sc-stamp__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(0,0,0,0.08);
    z-index: 2;
}
.sc-stamp__progress-fill {
    height: 100%;
    background: var(--accent-gold);
    border-radius: 0 2px 2px 0;
    transition: width 0.3s ease;
}

.sc-stamp__name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 4px 4px;
    background: linear-gradient(transparent, rgba(0,0,0,0.75));
    font-size: 9px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    z-index: 1;
}

/* --- Detail overlay content (inside #ticket-overlay-content) --- */
.sc-detail {
    padding: 0;
}
.sc-detail__artwork {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-height: 300px;
    background: var(--surface-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.sc-detail__artwork img,
.sc-detail__artwork video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sc-detail__artwork-placeholder {
    font-size: 64px;
    color: rgba(0,0,0,0.1);
}
.sc-detail__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) ease;
    z-index: 3;
}
.sc-detail__close:hover {
    background: rgba(231,76,60,0.4);
    border-color: var(--accent-red);
}
.sc-detail__earned-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: rgba(39,174,96,0.85);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    z-index: 3;
}

.sc-detail__body {
    padding: var(--space-md);
}
.sc-detail__title {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--ink);
    margin: 0 0 var(--space-xs);
}
.sc-detail__rarity {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    margin-bottom: var(--space-md);
}
.sc-detail__rarity--common {
    background: rgba(0,0,0,0.06);
    color: rgba(0,0,0,0.5);
}
.sc-detail__rarity--rare {
    background: rgba(52,152,219,0.2);
    color: #3498db;
}
.sc-detail__rarity--epic {
    background: rgba(155,89,182,0.2);
    color: #9b59b6;
}
.sc-detail__rarity--legendary {
    background: rgba(243,156,18,0.2);
    color: #f39c12;
}

.sc-detail__desc {
    font-size: 13px;
    color: rgba(0,0,0,0.55);
    line-height: 1.5;
    margin-bottom: var(--space-md);
}

/* Rewards display */
.sc-detail__rewards {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--surface-card);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
}
.sc-detail__reward {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sc-detail__reward-icon {
    font-size: 18px;
}
.sc-detail__reward-value {
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--accent-blue);
}
.sc-detail__reward-label {
    font-size: 11px;
    color: rgba(0,0,0,0.45);
}
.sc-detail__reward--multiplier .sc-detail__reward-value {
    color: #b38728;
}

/* Departing banner */
.sc-detail__departing {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(231,76,60,0.1);
    border: 1px solid rgba(231,76,60,0.25);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    font-size: 12px;
    color: var(--accent-red);
    font-weight: 600;
}

/* Task list */
.sc-detail__tasks-header {
    font-family: var(--font-display);
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(0,0,0,0.45);
    margin-bottom: var(--space-sm);
}
.sc-detail__tasks {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: var(--space-md);
    max-height: 35vh;
    overflow-y: auto;
}
.sc-detail__task {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-sm);
    border-radius: var(--radius-sm);
    border-left: 3px solid rgba(0,0,0,0.1);
    transition: background var(--duration-fast) ease;
    cursor: pointer;
}
.sc-detail__task:hover {
    background: rgba(0,0,0,0.04);
}
.sc-detail__task--complete {
    opacity: 0.5;
    border-left-color: var(--accent-green);
}
.sc-detail__task-status {
    font-size: 16px;
    flex-shrink: 0;
    color: rgba(0,0,0,0.2);
}
.sc-detail__task--complete .sc-detail__task-status {
    color: var(--accent-green);
}
.sc-detail__task-info {
    flex: 1;
    min-width: 0;
}
.sc-detail__task-title {
    font-size: 12px;
    color: var(--ink);
    font-weight: 500;
}
.sc-detail__task-meta {
    font-size: 10px;
    color: rgba(0,0,0,0.4);
    margin-top: 1px;
}
.sc-detail__task-find {
    background: rgba(110,142,255,0.2);
    color: #6E8EFF;
    border: 1px solid rgba(110,142,255,0.3);
    font-size: 10px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--duration-fast) ease;
}
.sc-detail__task-find:hover {
    background: rgba(110,142,255,0.35);
    transform: scale(1.05);
}

/* CTA button */
.sc-detail__cta {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    border: none;
    transition: all var(--duration-normal) ease;
}
.sc-detail__cta--accept {
    background: linear-gradient(135deg, var(--accent-gold), #f39c12);
    color: var(--ink);
}
.sc-detail__cta--accept:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255,217,61,0.3);
}
.sc-detail__cta--tracked {
    background: transparent;
    border: 1px solid rgba(0,0,0,0.15);
    color: rgba(0,0,0,0.5);
}
.sc-detail__cta--tracked:hover {
    border-color: var(--accent-red);
    color: var(--accent-red);
}
.sc-detail__cta--earned {
    background: rgba(39,174,96,0.2);
    border: 1px solid rgba(39,174,96,0.4);
    color: var(--accent-green);
    cursor: default;
}
.sc-detail__cta--locked {
    background: linear-gradient(135deg, var(--accent-gold), #f39c12);
    color: var(--ink);
}
.sc-detail__cta--locked:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(255,217,61,0.3);
}

/* Footer actions (unpin) */
.sc-detail__footer {
    display: flex;
    justify-content: center;
    margin-top: var(--space-sm);
}
.sc-detail__unpin {
    background: none;
    border: none;
    color: rgba(0,0,0,0.3);
    font-size: 11px;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    transition: color var(--duration-fast) ease;
}
.sc-detail__unpin:hover {
    color: var(--accent-red);
}

/* --- Loading & error states --- */
.sc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: var(--space-sm);
    color: rgba(0,0,0,0.45);
    font-size: 13px;
}
.sc-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(0,0,0,0.08);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: sc-spin 0.8s linear infinite;
}
.sc-error {
    text-align: center;
    padding: var(--space-xl);
    color: rgba(0,0,0,0.45);
}
.sc-error__retry {
    margin-top: var(--space-sm);
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(0,0,0,0.15);
    background: transparent;
    color: var(--ink);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--duration-fast) ease;
}
.sc-error__retry:hover {
    background: var(--surface-card);
    border-color: rgba(0,0,0,0.3);
}

/* --- Animations --- */
@keyframes sc-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes sc-fadeSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes sc-spin {
    to { transform: rotate(360deg); }
}
@keyframes sc-depart-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0); }
    50% { box-shadow: 0 0 8px 2px rgba(231,76,60,0.35); }
}
@keyframes sc-legendary-shimmer {
    0%, 100% { border-color: #f39c12; box-shadow: 0 0 6px rgba(243,156,18,0.15); }
    50% { border-color: #f1c40f; box-shadow: 0 0 12px rgba(241,196,15,0.3); }
}

/* --- Grid stamp stagger animation --- */
.sc-grid .sc-stamp {
    animation: sc-fadeSlideUp 0.4s ease both;
}
.sc-grid .sc-stamp:nth-child(1) { animation-delay: 0s; }
.sc-grid .sc-stamp:nth-child(2) { animation-delay: 0.03s; }
.sc-grid .sc-stamp:nth-child(3) { animation-delay: 0.06s; }
.sc-grid .sc-stamp:nth-child(4) { animation-delay: 0.09s; }
.sc-grid .sc-stamp:nth-child(5) { animation-delay: 0.12s; }
.sc-grid .sc-stamp:nth-child(6) { animation-delay: 0.15s; }
.sc-grid .sc-stamp:nth-child(7) { animation-delay: 0.18s; }
.sc-grid .sc-stamp:nth-child(8) { animation-delay: 0.21s; }
.sc-grid .sc-stamp:nth-child(9) { animation-delay: 0.24s; }
.sc-grid .sc-stamp:nth-child(10) { animation-delay: 0.27s; }
.sc-grid .sc-stamp:nth-child(11) { animation-delay: 0.30s; }
.sc-grid .sc-stamp:nth-child(12) { animation-delay: 0.33s; }
.sc-grid .sc-stamp:nth-child(n+13) { animation-delay: 0.36s; }
