/* ============================================================
   Buttons (icon + shutter)
   ============================================================ */

.icon-btn {
    background: transparent;
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    color: var(--hf-text-dim);
    width: 36px;
    height: 36px;
    border-radius: var(--hf-radius-full);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: var(--hf-transition-color), var(--hf-transition-border), var(--hf-transition-bg);
    flex-shrink: 0;
}

.icon-btn:hover {
    border-color: var(--hf-accent);
    color: var(--hf-text-bright);
}

.icon-btn.active {
    background: var(--hf-bg-elevated);
    border-color: var(--hf-accent);
    color: var(--hf-text-bright);
}

button:focus-visible,
.starter-chip:focus-visible {
    outline: var(--hf-focus-ring-width) solid var(--hf-focus-ring-color);
    outline-offset: var(--hf-focus-ring-offset);
}

/* ============================================================
   Mode toggle (Photo / Video)
   ============================================================ */

.mode-toggle {
    display: flex;
    border-radius: var(--hf-radius-pill);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    overflow: hidden;
}

.mode-btn {
    background: transparent;
    border: none;
    color: var(--hf-text-dim);
    padding: var(--hf-space-1) var(--hf-space-3);
    font-family: inherit;
    font-size: var(--hf-size-xs);
    letter-spacing: var(--hf-tracking-wide);
    cursor: pointer;
    transition: var(--hf-transition-color), var(--hf-transition-bg);
}

.mode-btn.active {
    background: var(--hf-bg-elevated);
    color: var(--hf-text-bright);
}

/* ============================================================
   Shutter button
   ============================================================ */

.shutter-btn {
    width: 64px;
    height: 64px;
    border-radius: var(--hf-radius-full);
    border: 3px solid var(--hf-text-bright);
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: var(--hf-transition-border);
    flex-shrink: 0;
}

.shutter-btn::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: var(--hf-radius-full);
    background: var(--hf-text-bright);
    transition: background 0.15s, border-radius 0.15s, inset 0.15s;
}

.shutter-btn:hover { border-color: var(--hf-accent); }

.shutter-btn.video-mode { border-color: var(--hf-red); }
.shutter-btn.video-mode::after { background: var(--hf-red); }
.shutter-btn.video-mode:hover { border-color: var(--hf-red); }

.shutter-btn.recording::after {
    border-radius: var(--hf-radius-sm);
    inset: 18px;
}

/* ============================================================
   GLITCHIFY button
   ============================================================ */

.glitchify-btn {
    position: relative;
    background: var(--hf-accent);
    color: var(--hf-bg-base);
    font-family: inherit;
    font-weight: var(--hf-weight-bold);
    letter-spacing: var(--hf-tracking-wide);
    font-size: var(--hf-size-sm);
    padding: 0 var(--hf-space-4);
    height: 44px;
    border: var(--hf-border-width) solid var(--hf-accent);
    border-radius: var(--hf-radius-sm);
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.08s, background 0.15s;
    flex: 1;
    min-width: 0;
}

.glitchify-label { position: relative; z-index: 1; }

.glitchify-btn:hover { background: var(--hf-accent-hover); }

.glitchify-btn:active,
.glitchify-btn.pulse {
    transform: translateY(1px);
}

/* ============================================================
   RE-ROLL ALL + SHARE buttons
   ============================================================ */

.reroll-all-btn,
.share-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--hf-space-2);
    height: 44px;
    padding: 0 var(--hf-space-3);
    background: var(--hf-bg-base);
    color: var(--hf-text-normal);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    border-radius: var(--hf-radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--hf-size-xs);
    font-weight: var(--hf-weight-bold);
    letter-spacing: var(--hf-tracking-wide);
    transition: var(--hf-transition-color), var(--hf-transition-border);
    flex-shrink: 0;
}

.reroll-all-btn:hover,
.share-btn:hover {
    border-color: var(--hf-accent);
    color: var(--hf-text-bright);
}

/* ============================================================
   Toast
   ============================================================ */

.glitch-toast {
    position: fixed;
    left: 50%;
    bottom: calc(120px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: var(--hf-bg-elevated);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    color: var(--hf-text-normal);
    padding: var(--hf-space-2) var(--hf-space-4);
    border-radius: var(--hf-radius-md);
    font-size: var(--hf-size-sm);
    z-index: 200;
    pointer-events: none;
    box-shadow: var(--hf-shadow-md);
    animation: toast-life 2.2s ease-in-out forwards;
}

@keyframes toast-life {
    0%   { opacity: 0; transform: translate(-50%, 12px); }
    10%  { opacity: 1; transform: translate(-50%, 0); }
    85%  { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* ============================================================
   Stack slots
   ============================================================ */

.stack-empty {
    padding: var(--hf-space-4) var(--hf-space-3);
    text-align: center;
    color: var(--hf-text-dim);
    font-size: var(--hf-size-sm);
    border: var(--hf-border-width) dashed var(--hf-border-subtle);
    border-radius: var(--hf-radius-sm);
}

.stack-slot {
    display: grid;
    grid-template-columns: auto minmax(90px, 130px) 1fr auto auto;
    align-items: center;
    gap: var(--hf-space-3);
    padding: var(--hf-space-2) var(--hf-space-3);
    background: var(--hf-bg-base);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    border-radius: var(--hf-radius-sm);
    transition: var(--hf-transition-border), opacity 0.1s;
    position: relative;
}

.stack-slot:hover { border-color: var(--hf-accent); }

.stack-slot.dragging { opacity: 0.5; }

/* Outset shadow above/below the row indicates drop position */
.stack-slot.drag-over-top { box-shadow: 0 -3px 0 0 var(--hf-accent); }
.stack-slot.drag-over-bottom { box-shadow: 0 3px 0 0 var(--hf-accent); }

.slot-handle {
    color: var(--hf-text-dim);
    cursor: grab;
    font-size: var(--hf-size-base);
    line-height: 1;
    letter-spacing: -3px;
    user-select: none;
    width: 28px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Disable browser gestures during drag so a finger drag actually
       reorders the slot instead of scrolling/panning the page. */
    touch-action: none;
    border-radius: var(--hf-radius-sm);
    transition: var(--hf-transition-bg), var(--hf-transition-color);
}

.slot-handle:hover {
    background: var(--hf-bg-elevated);
    color: var(--hf-text-normal);
}

.slot-handle:active { cursor: grabbing; }

.slot-name {
    color: var(--hf-text-bright);
    font-size: var(--hf-size-sm);
    font-weight: var(--hf-weight-semibold);
    letter-spacing: var(--hf-tracking-wide);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-intensity {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--hf-space-3);
    min-width: 0;
}

.slot-intensity-slider {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    width: 100%;
    height: 28px;
    cursor: pointer;
}

.slot-intensity-slider::-webkit-slider-runnable-track {
    height: 3px;
    background: var(--hf-bg-elevated);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    border-radius: 2px;
}
.slot-intensity-slider::-moz-range-track {
    height: 3px;
    background: var(--hf-bg-elevated);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    border-radius: 2px;
}

.slot-intensity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--hf-accent);
    border-radius: var(--hf-radius-full);
    border: 2px solid var(--hf-bg-base);
    margin-top: -6px;
    cursor: pointer;
}
.slot-intensity-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--hf-accent);
    border-radius: var(--hf-radius-full);
    border: 2px solid var(--hf-bg-base);
    cursor: pointer;
}

.slot-intensity-value {
    color: var(--hf-text-normal);
    font-variant-numeric: tabular-nums;
    font-family: var(--hf-font-family-mono);
    font-size: var(--hf-size-xs);
    font-weight: var(--hf-weight-bold);
    width: 26px;
    text-align: right;
}

.slot-dice {
    background: transparent;
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    color: var(--hf-text-dim);
    width: 30px;
    height: 30px;
    border-radius: var(--hf-radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--hf-transition-color), var(--hf-transition-border);
    flex-shrink: 0;
}

.slot-dice:hover {
    border-color: var(--hf-accent);
    color: var(--hf-accent);
}

.slot-dice.rolling { animation: dice-roll 0.45s ease-out; }

@keyframes dice-roll {
    0%   { transform: rotate(0deg); }
    50%  { transform: rotate(180deg) scale(1.15); }
    100% { transform: rotate(360deg); }
}

.slot-remove {
    background: transparent;
    border: var(--hf-border-width) solid transparent;
    color: var(--hf-text-dim);
    width: 24px;
    height: 24px;
    border-radius: var(--hf-radius-full);
    cursor: pointer;
    font-size: var(--hf-size-md);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: var(--hf-transition-color), var(--hf-transition-border);
    flex-shrink: 0;
}

.slot-remove:hover {
    color: var(--hf-red);
    border-color: var(--hf-red);
}

/* ============================================================
   Add-effect button + picker
   ============================================================ */

.add-effect-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--hf-space-1);
    background: transparent;
    border: var(--hf-border-width) dashed var(--hf-border-subtle);
    color: var(--hf-text-dim);
    padding: var(--hf-space-1) var(--hf-space-3);
    border-radius: var(--hf-radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: var(--hf-size-xs);
    font-weight: var(--hf-weight-bold);
    letter-spacing: var(--hf-tracking-wide);
    transition: var(--hf-transition-color), var(--hf-transition-border);
}

.add-effect-btn:hover,
.add-effect-btn.active {
    border-color: var(--hf-accent);
    border-style: solid;
    color: var(--hf-text-bright);
}

.add-effect-plus {
    font-size: var(--hf-size-sm);
    font-weight: var(--hf-weight-bold);
    color: var(--hf-accent);
}

.effect-picker {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: var(--hf-bg-elevated);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    border-radius: var(--hf-radius-md);
    padding: var(--hf-space-1);
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 50;
    min-width: 240px;
    max-height: 320px;
    overflow-y: auto;
    box-shadow: var(--hf-shadow-lg);
}

.effect-picker.open { display: flex; }

.effect-picker-item {
    background: transparent;
    border: none;
    color: var(--hf-text-normal);
    text-align: left;
    padding: var(--hf-space-2) var(--hf-space-3);
    border-radius: var(--hf-radius-sm);
    cursor: pointer;
    font-family: inherit;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: var(--hf-transition-bg);
}

.effect-picker-item:hover { background: var(--hf-bg-muted); }

.picker-name {
    font-size: var(--hf-size-sm);
    font-weight: var(--hf-weight-semibold);
    letter-spacing: var(--hf-tracking-wide);
    color: var(--hf-text-bright);
}

.picker-tag {
    font-size: var(--hf-size-xs);
    color: var(--hf-text-dim);
}

/* ============================================================
   Starter chips
   ============================================================ */

.starter-chip {
    flex-shrink: 0;
    scroll-snap-align: start;
    background: transparent;
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    color: var(--hf-text-dim);
    font-family: inherit;
    font-size: var(--hf-size-xs);
    letter-spacing: var(--hf-tracking-wide);
    padding: var(--hf-space-1) var(--hf-space-3);
    border-radius: var(--hf-radius-sm);
    cursor: pointer;
    transition: var(--hf-transition-color), var(--hf-transition-border);
    text-transform: uppercase;
    white-space: nowrap;
    position: relative;
}

.starter-chip:hover {
    color: var(--hf-text-bright);
    border-color: var(--hf-accent);
}

/* ============================================================
   Recording indicator
   ============================================================ */

.recording-indicator {
    display: flex;
    align-items: center;
    gap: var(--hf-space-2);
    color: var(--hf-red);
    font-size: var(--hf-size-sm);
    font-variant-numeric: tabular-nums;
    font-family: var(--hf-font-family-mono);
    flex-shrink: 0;
}

.recording-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--hf-radius-full);
    background: var(--hf-red);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.3; }
}

/* ============================================================
   Error banner
   ============================================================ */

.error-banner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--hf-space-6);
    background: var(--hf-bg-base);
    z-index: 5;
}

.error-title {
    font-size: var(--hf-size-md);
    margin-bottom: var(--hf-space-2);
    color: var(--hf-text-bright);
}

.error-body {
    font-size: var(--hf-size-sm);
    color: var(--hf-text-dim);
    max-width: 360px;
}

/* ============================================================
   Filmstrip
   ============================================================ */

.filmstrip-thumbs {
    display: flex;
    gap: var(--hf-space-2);
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 240px;
}

.filmstrip-thumbs::-webkit-scrollbar { display: none; }

.filmstrip-item {
    position: relative;
    flex-shrink: 0;
}

.filmstrip-thumb {
    width: 44px;
    height: 44px;
    border-radius: var(--hf-radius-sm);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    cursor: pointer;
    object-fit: cover;
    display: block;
    transition: var(--hf-transition-border);
}

.filmstrip-item:hover .filmstrip-thumb { border-color: var(--hf-accent); }

.filmstrip-delete {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    border-radius: var(--hf-radius-full);
    border: none;
    background: var(--hf-bg-elevated);
    color: var(--hf-text-normal);
    font-size: var(--hf-size-sm);
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: var(--hf-shadow-sm);
}

.filmstrip-item:hover .filmstrip-delete { display: flex; }

@media (hover: none) {
    .filmstrip-delete { display: flex; }
}

/* ============================================================
   Flash / pulse overlays
   ============================================================ */

.flash-overlay {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 101;
    pointer-events: none;
    animation: flash 0.3s ease-out forwards;
}

@keyframes flash {
    0%   { opacity: 0.8; }
    100% { opacity: 0; }
}

.glitch-pulse-overlay {
    position: fixed;
    inset: 0;
    background: var(--hf-accent);
    z-index: 101;
    pointer-events: none;
    mix-blend-mode: difference;
    animation: glitch-pulse 0.35s ease-out forwards;
}

@keyframes glitch-pulse {
    0%   { opacity: 0.5; }
    100% { opacity: 0; }
}

/* ============================================================
   Settings dialog
   ============================================================ */

.settings-dialog {
    background: var(--hf-bg-surface);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    border-radius: var(--hf-radius-lg);
    color: var(--hf-text-normal);
    padding: 0;
    margin: auto;
    position: fixed;
    inset: 0;
    max-width: 480px;
    width: 90vw;
    max-height: 85vh;
    overflow: hidden;
    outline: none;
    box-shadow: var(--hf-shadow-xl);
}

.settings-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.settings-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--hf-space-4) var(--hf-space-5);
    border-bottom: var(--hf-border-width) solid var(--hf-border-subtle);
}

.settings-dialog-head h2 {
    font-family: var(--hf-font-family);
    font-size: var(--hf-size-lg);
    font-weight: var(--hf-weight-bold);
    color: var(--hf-text-bright);
    letter-spacing: var(--hf-tracking-wide);
}

.settings-dialog-body {
    padding: var(--hf-space-4) var(--hf-space-5);
    overflow-y: auto;
    max-height: calc(85vh - 70px);
}

.settings-section {
    padding-bottom: var(--hf-space-4);
}

.settings-section + .settings-section {
    padding-top: var(--hf-space-4);
    border-top: var(--hf-border-width) solid var(--hf-border-subtle);
}

.settings-section h3 {
    font-size: var(--hf-size-xs);
    letter-spacing: var(--hf-tracking-wide);
    text-transform: uppercase;
    color: var(--hf-text-dim);
    margin-bottom: var(--hf-space-3);
    font-family: var(--hf-font-family-mono);
}

.settings-row {
    display: flex;
    align-items: center;
    gap: var(--hf-space-3);
    margin-bottom: var(--hf-space-3);
    flex-wrap: wrap;
}

.settings-row label {
    font-size: var(--hf-size-sm);
    color: var(--hf-text-dim);
    min-width: 80px;
}

.theme-picker-host { flex: 1 1 160px; display: flex; }

.hf-theme-select {
    flex: 1 1 auto;
    background: var(--hf-bg-base);
    border: var(--hf-border-width) solid var(--hf-border-subtle);
    color: var(--hf-text-normal);
    border-radius: var(--hf-radius-sm);
    padding: var(--hf-space-2) var(--hf-space-3);
    font-size: var(--hf-size-sm);
    font-family: inherit;
    outline: none;
    cursor: pointer;
}
.hf-theme-select:focus { border-color: var(--hf-accent); }

.settings-hint {
    font-size: var(--hf-size-xs);
    color: var(--hf-text-dim);
    line-height: var(--hf-leading-normal);
    margin-top: var(--hf-space-1);
}

/* ============================================================
   Utility
   ============================================================ */

.hidden { display: none !important; }

button, .starter-chip, .effect-picker-item {
    touch-action: manipulation;
}

/* On narrow viewports keep the slot row legible */
@media (max-width: 600px) {
    .stack-slot {
        grid-template-columns: auto minmax(70px, 100px) 1fr auto auto;
        gap: var(--hf-space-2);
        padding: var(--hf-space-1) var(--hf-space-2);
    }
    .slot-name { font-size: var(--hf-size-xs); }
}
