/*
 * steg.css - ImageSteg (Steghide) page styles
 * Depends on the design tokens in css/modules/common.css
 */

.steg-page [hidden] {
    display: none !important;
}

.steg-page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 1.6rem 1.25rem 3rem;
}

.steg-card {
    padding: 1.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--box-shadow);
}

/* ========== mode switch ========== */
.steg-mode-switch {
    display: inline-flex;
    gap: 0.3rem;
    margin-bottom: 1.1rem;
    padding: 0.35rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

.steg-mode {
    min-width: 130px;
    padding: 0.5rem 1.1rem;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--light-text);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.steg-mode:hover {
    color: var(--text-color);
}

.steg-mode.active {
    background: var(--surface);
    color: var(--primary-hover);
    box-shadow: var(--box-shadow);
}

/* ========== progress bar ========== */
.steg-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.1rem;
}

.steg-progress-track {
    flex: 1;
    height: 8px;
    overflow: hidden;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

.steg-progress-bar {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #f97316);
    border-radius: 999px;
    transition: width 0.18s ease;
}

.steg-progress span {
    color: var(--light-text);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ========== three column layout ========== */
.steg-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.1rem;
}

.steg-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.1rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.steg-column h2,
.steg-column-wide h2 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.steg-column-wide {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ========== drop zone ========== */
.steg-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 1.6rem 1rem;
    text-align: center;
    background: var(--surface);
    border: 1.5px dashed #cbd5e1;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

.steg-dropzone:hover,
.steg-dropzone.dragging {
    border-color: var(--primary-color);
    background: var(--primary-soft);
}

.steg-dropzone i {
    color: var(--primary-color);
    font-size: 1.6rem;
}

.steg-dropzone strong {
    font-size: 0.92rem;
}

.steg-dropzone span {
    color: var(--light-text);
    font-size: 0.8rem;
}

/* ========== file cards ========== */
.steg-file-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.steg-file-card canvas {
    flex: 0 0 auto;
    width: 92px;
    height: 92px;
    object-fit: cover;
    background: #eef2f7;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.steg-file-card img {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    background: #eef2f7;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.steg-file-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    font-size: 0.82rem;
}

.steg-file-meta strong {
    overflow: hidden;
    font-size: 0.88rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.steg-capacity {
    color: var(--light-text);
}

.steg-source {
    padding: 0.15rem 0.45rem;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 6px;
    color: #92400e;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.4;
}

.steg-verified {
    flex: 0 0 auto;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: rgba(4, 120, 87, 0.12);
    color: #047857;
    font-size: 0.75rem;
    font-weight: 700;
}

.steg-capacity strong {
    color: var(--text-color);
}

/* ========== segmented control ========== */
.steg-segmented {
    display: grid;
    grid-auto-flow: column;
    gap: 0.3rem;
    padding: 0.3rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.steg-segmented button {
    padding: 0.45rem 0.6rem;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--light-text);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.steg-segmented button.active {
    background: var(--primary-color);
    color: #fff;
}

.steg-secret-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.83rem;
}

.steg-link {
    border: none;
    background: none;
    color: var(--primary-color);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

/* ========== forms ========== */
.steg-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.steg-field > span {
    color: var(--light-text);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.steg-required {
    margin-left: 0.25rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-hover);
    font-size: 0.68rem;
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.steg-input,
.steg-select,
.steg-textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.9rem;
}

.steg-input:focus,
.steg-select:focus,
.steg-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.steg-textarea {
    min-height: 118px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.steg-passphrase {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
}

.steg-passphrase input {
    flex: 1;
}

.steg-icon-button {
    display: inline-flex;
    align-items: center;
    padding: 0 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--light-text);
    cursor: pointer;
}

.steg-icon-button:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.steg-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.steg-check input {
    margin-top: 0.28rem;
    accent-color: var(--primary-color);
}

.steg-check small {
    display: block;
    color: var(--light-text);
    font-size: 0.76rem;
}

.steg-hint {
    color: var(--light-text);
    font-size: 0.78rem;
}

.steg-actions {
    margin-top: auto;
}

.steg-actions .btn {
    width: 100%;
}

.steg-status {
    padding: 0.6rem 0.8rem;
    border-radius: var(--border-radius);
    font-size: 0.83rem;
    font-weight: 600;
}

.steg-status[data-kind='error'] {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.steg-status[data-kind='success'] {
    color: #047857;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.steg-status[data-kind='info'] {
    color: var(--light-text);
    background: var(--surface);
    border: 1px solid var(--border-color);
}

/* ========== results ========== */
.steg-result {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.1rem;
    padding: 1rem 1.15rem;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-lg);
}

.steg-result span {
    flex: 1;
    min-width: 220px;
    color: #047857;
    font-size: 0.86rem;
    font-weight: 600;
}

.steg-result .btn {
    text-decoration: none;
}

/* Compact player for an audio cover in the file card */
.steg-preview-audio {
    flex: 0 0 auto;
    width: 210px;
    height: 36px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

/* Player inside the reveal ritual stage when the cover is audio */
.steg-ritual-audio {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 24px);
    z-index: 2;
}

/* Recovered payload, rendered according to its type */
.steg-payload-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 520px;
    margin-top: 0.9rem;
    background: #eef2f7;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    object-fit: contain;
}

.steg-payload-audio {
    display: block;
    width: 100%;
    margin-top: 0.9rem;
}

/* ========== writable space readout ========== */
/* Shown as soon as a container is loaded, so the capacity of the exact file
   in front of the user is known before anything is typed. */
.steg-capacity-card {
    margin-top: 0.9rem;
    padding: 0.85rem 0.95rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.steg-capacity-head {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--light-text);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.steg-capacity-head i {
    color: var(--primary-color);
}

.steg-capacity-figures {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.4rem;
    margin-top: 0.7rem;
}

.steg-capacity-figures div {
    display: flex;
    flex-direction: column;
}

.steg-capacity-figures strong {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-color);
}

.steg-capacity-figures span {
    font-size: 0.76rem;
    color: var(--light-text);
}

.steg-capacity-track {
    height: 7px;
    margin-top: 0.75rem;
    background: var(--border-color);
    border-radius: 999px;
    overflow: hidden;
}

.steg-capacity-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #34d399, #059669);
    border-radius: 999px;
    transition: width 0.25s ease;
}

.steg-capacity-fill.over {
    background: linear-gradient(90deg, #fbbf24, #dc2626);
}

.steg-capacity-note {
    margin: 0.6rem 0 0;
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--light-text);
}

.steg-capacity-note.over {
    color: #b91c1c;
    font-weight: 600;
}

.steg-subhead {
    margin: 1.5rem 0 0.4rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.steg-subcopy {
    max-width: 760px;
    margin-bottom: 0.9rem;
    color: var(--light-text);
}

.steg-bullets {
    display: grid;
    gap: 0.6rem;
    max-width: 860px;
    padding-left: 1.1rem;
    list-style: disc;
}

.steg-bullets li {
    color: var(--light-text);
    font-size: 0.88rem;
    line-height: 1.6;
}

.steg-bullets strong {
    color: var(--text-color);
}

/* ========== extract panel ========== */
.steg-extract-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 1.1rem;
    align-items: start;
}

/* ========== hints and notes ========== */
.steg-note {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.1rem;
    padding: 0.85rem 1rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--light-text);
    font-size: 0.83rem;
}

.steg-note i {
    margin-top: 0.2rem;
    color: var(--primary-color);
}

.steg-note strong {
    color: var(--text-color);
}

/* Lossy compression destroys the payload: a deliberately loud warning style */
.steg-note-warn {
    color: #92400e;
    background: #fffbeb;
    border-color: #fcd34d;
}

.steg-note-warn i {
    color: #f59e0b;
}

.steg-note-warn strong {
    color: #78350f;
}

.steg-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.7rem;
}

.steg-fact {
    padding: 0.85rem 1rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.steg-fact strong {
    display: block;
    font-size: 1.05rem;
}

.steg-fact span {
    color: var(--light-text);
    font-size: 0.78rem;
}

/* ========== toast ========== */
.steg-toast {
    position: fixed;
    left: 50%;
    bottom: 1.6rem;
    z-index: 900;
    max-width: min(560px, calc(100vw - 2rem));
    padding: 0.7rem 1.1rem;
    background: #0f172a;
    border-radius: 999px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: translate(-50%, 12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.steg-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.steg-page.is-busy .steg-actions .btn {
    opacity: 0.55;
}

body.is-busy {
    cursor: progress;
}

/* ========== responsive ========== */
@media (max-width: 980px) {
    .steg-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .steg-extract-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 720px) {
    .steg-page {
        padding: 1.1rem 0.9rem 2.5rem;
    }

    .steg-card {
        padding: 1.1rem;
    }

    .steg-mode {
        min-width: 0;
        flex: 1;
    }

    .steg-result .btn {
        width: 100%;
    }
}

/* ========== privacy notice ========== */
/* Prominent, always visible reassurance that nothing leaves the device. */
.steg-privacy {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    margin: 0 0 1.1rem;
    padding: 0.8rem 1rem;
    background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
    border: 1px solid #34d399;
    border-left: 4px solid #10b981;
    border-radius: var(--border-radius);
}

.steg-privacy i {
    color: #059669;
    font-size: 1.15rem;
    margin-top: 0.1rem;
}

.steg-privacy p {
    margin: 0;
    color: #065f46;
    font-size: 0.88rem;
    line-height: 1.55;
}

.steg-privacy strong {
    color: #047857;
}

/* ========== revealing ritual ========== */
/* The extract panel has no button: three full circles drawn around the
   image with the pointer cast the reveal. The stage hosts the preview,
   the glowing trail canvas and the veil that flashes on the cast. */
.steg-ritual-stage {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    height: 220px;
    overflow: hidden;
    border-radius: var(--border-radius);
    cursor: crosshair;
    touch-action: none;
}

.steg-ritual-stage:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.steg-ritual-stage img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #eef2f7;
}

.steg-ritual-stage .steg-trail {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    object-fit: fill;
    pointer-events: none;
    mix-blend-mode: screen;
}

.steg-ritual-veil {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #fff;
    background: radial-gradient(circle, rgba(255, 200, 80, 0.45), rgba(124, 58, 237, 0.28) 60%, transparent 78%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.steg-ritual-stage.casting {
    box-shadow: 0 0 0 2px var(--primary-color), 0 0 34px rgba(250, 184, 60, 0.55);
}

.steg-ritual-stage.casting .steg-ritual-veil {
    opacity: 1;
    animation: steg-veil-pulse 0.75s ease;
}

@keyframes steg-veil-pulse {
    0% {
        transform: scale(0.86);
    }

    60% {
        transform: scale(1.04);
    }

    100% {
        transform: scale(1);
    }
}

.steg-ritual {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-top: 0.9rem;
    padding: 0.85rem 0.95rem;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.steg-ritual-copy {
    margin: 0;
    color: var(--text-color);
    font-size: 0.88rem;
    line-height: 1.55;
}

.steg-ritual-copy i {
    color: var(--primary-color);
    margin-right: 0.35rem;
}

.steg-ritual-copy .steg-ritual-highlight {
    color: #ea580c;
    font-weight: 700;
}

.steg-ritual-moons {
    display: flex;
    gap: 0.55rem;
    align-items: center;
}

.steg-moon {
    width: 15px;
    height: 15px;
    border: 1.5px solid var(--border-color);
    border-radius: 50%;
    background: var(--surface);
    transition: background 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.steg-moon.lit {
    border-color: #f59e0b;
    background: radial-gradient(circle at 35% 35%, #ffe9a8, #f59e0b);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.75);
    transform: scale(1.12);
}

/* A big handwritten number that pops and floats up each time a circle closes. */
.steg-ritual-number {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Brush Script MT', 'Segoe Script', 'Snell Roundhand', 'Comic Sans MS', cursive;
    font-size: 5.5rem;
    font-weight: 700;
    line-height: 1;
    color: #ffd166;
    text-shadow: 0 0 18px rgba(250, 184, 60, 0.95), 0 0 6px rgba(255, 255, 255, 0.85);
    pointer-events: none;
    user-select: none;
    z-index: 6;
    animation: steg-number-pop 1.1s ease-out forwards;
}

@keyframes steg-number-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.2) rotate(-18deg);
    }
    35% {
        opacity: 1;
        transform: translate(-50%, -55%) scale(1.25) rotate(8deg);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -95%) scale(1.05) rotate(0deg);
    }
}

/* The recovered data bounces in instead of just appearing. */
.steg-reveal-pop {
    animation: steg-reveal-pop 0.62s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes steg-reveal-pop {
    0% {
        opacity: 0;
        transform: scale(0.82) translateY(16px);
    }
    60% {
        opacity: 1;
        transform: scale(1.03) translateY(-4px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Nudge the passphrase field when a protected image needs its key. */
.steg-shake {
    animation: steg-shake 0.5s ease;
}

/* Draws the eye to the passphrase field the moment a file is loaded. */
.steg-flash {
    animation: steg-flash 0.75s ease-in-out 3;
}

@keyframes steg-flash {
    0%,
    100% {
        border-color: var(--border-color);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
    50% {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.22);
    }
}

@media (prefers-reduced-motion: reduce) {
    .steg-flash {
        animation: none;
    }
}

@keyframes steg-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

@media (prefers-reduced-motion: reduce) {
    .steg-ritual-number,
    .steg-reveal-pop,
    .steg-shake {
        animation: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .steg-ritual-stage.casting .steg-ritual-veil {
        animation: none;
    }

    .steg-moon {
        transition: none;
    }
}
