/* ═══════════════════════════════════════════
   GTIN.Snap — Stylesheet
   GS1 compliant product image capture tool
═══════════════════════════════════════════ */

:root {
    --ink:     #0a0a0a;
    --paper:   #f5f2eb;
    --accent:  #ff4d1c;
    --muted:   #888;
    --border:  #d8d4cb;
    --card:    #fffef9;
    --success: #00b87a;
    --error:   #e0000f;
    --radius:  16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: var(--paper);
    color: var(--ink);
    font-family: 'DM Sans', sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ── SCREENS ── */
.screen {
    display: none;
    min-height: 100dvh;
    flex-direction: column;
    align-items: center;
    padding: 0 20px 40px;
}
.screen.active {
    display: flex;
    animation: slideUp .32s cubic-bezier(.16,1,.3,1) both;
}
@keyframes slideUp {
    from { opacity:0; transform:translateY(16px); }
    to   { opacity:1; transform:translateY(0); }
}

/* ── TOPBAR ── */
.topbar {
    width: 100%; max-width: 420px;
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 0 12px;
    flex-shrink: 0;
}
.logo {
    font-family: 'Syne', sans-serif;
    font-weight: 800; font-size: 17px; letter-spacing: -.3px;
    text-transform: uppercase;
    white-space: nowrap;
}
.logo span { color: var(--accent); }
.badge {
    font-family: 'DM Mono', monospace;
    font-size: 11px; background: var(--ink); color: var(--paper);
    padding: 4px 10px; border-radius: 20px;
    white-space: nowrap; flex-shrink: 0;
}

/* ── BUTTONS — base ──
   min-width on flex children prevents shrink on small screens */
.btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; max-width: 420px;
    min-height: 54px;
    padding: 0 20px;
    border: none; border-radius: var(--radius);
    font-family: 'DM Sans', sans-serif; font-size: 16px; font-weight: 600;
    cursor: pointer;
    transition: transform .12s, box-shadow .12s;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
    flex-shrink: 0;
    white-space: nowrap;
}
.btn:active  { transform: scale(.97); }
.btn:disabled{ opacity:.5; cursor:not-allowed; transform:none; }
.btn + .btn  { margin-top: 12px; }

.btn-primary  { background: var(--ink);     color: var(--paper); box-shadow: 0 4px 20px rgba(0,0,0,.18); }
.btn-secondary{ background: var(--card);    color: var(--ink);   border: 2px solid var(--border); }
.btn-success  { background: var(--success); color: #fff;         box-shadow: 0 4px 20px rgba(0,184,122,.28); }

.btn-ghost {
    background: none; border: none;
    color: var(--muted); font-size: 14px; font-weight: 500;
    cursor: pointer; padding: 8px 4px;
    white-space: nowrap; flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

/* ── SECTION HEAD ── */
.section-head { width: 100%; max-width: 420px; padding: 20px 0 8px; }
.section-head h2 {
    font-family: 'Syne', sans-serif; font-weight: 700;
    font-size: 22px; letter-spacing: -.5px;
}
.section-head p { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* ═══════════════════════════════════════════
   SCREEN 1 — HOME
═══════════════════════════════════════════ */
.home-hero {
    width: 100%; max-width: 420px;
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; padding-bottom: 20px;
}
.home-tagline {
    font-family: 'Syne', sans-serif; font-weight: 800;
    font-size: clamp(32px, 9vw, 46px);
    line-height: 1.05; letter-spacing: -1.5px; margin-bottom: 14px;
}
.home-tagline em { color: var(--accent); font-style: normal; }
.home-sub {
    font-size: 15px; color: #555; line-height: 1.6;
    margin-bottom: 28px; max-width: 320px;
}
.steps-preview { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 28px; }
.step-pill {
    font-family: 'DM Mono', monospace; font-size: 11px;
    border: 1.5px solid var(--border); border-radius: 20px;
    padding: 5px 12px; color: var(--muted);
}
/* Hidden SEO paragraph — visible to crawlers, not to users */
.seo-text {
    font-size: 0; height: 0; overflow: hidden;
    position: absolute; left: -9999px;
}

/* ═══════════════════════════════════════════
   SCREEN 2 — EAN INPUT
═══════════════════════════════════════════ */
.ean-entry-box {
    width: 100%; max-width: 420px;
    margin-top: 40px; text-align: center;
}
.ean-input-wrap { position: relative; margin-bottom: 20px; }
.ean-field {
    width: 100%; background: none; border: none;
    font-family: 'DM Mono', monospace;
    font-size: clamp(28px, 8vw, 38px);
    font-weight: 500; text-align: center; letter-spacing: 4px;
    color: var(--ink); outline: none; padding: 10px 0;
}
.ean-underline {
    height: 3px; width: 100%;
    background: var(--border); border-radius: 4px;
    position: relative; overflow: hidden;
}
.ean-underline::after {
    content: ''; position: absolute; left: 0; top: 0;
    height: 100%; width: 0;
    background: var(--accent); transition: width .3s ease;
}
.ean-field:focus + .ean-underline::after { width: 100%; }
.ean-hint { font-size: 12px; color: var(--muted); margin-top: 12px; }

/* ═══════════════════════════════════════════
   SCREEN 3 — GUIDED CAPTURE
═══════════════════════════════════════════ */
.top-bar {
    width: 100%; max-width: 420px;
    display: flex; align-items: center;
    padding: 16px 0; flex-shrink: 0;
}
.prog-dots { display: flex; gap: 6px; }
.dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--border);
    transition: background .3s, transform .3s;
}
.dot.done   { background: var(--success); }
.dot.active { background: var(--accent); transform: scale(1.4); }

.screen-content {
    width: 100%; max-width: 420px;
    flex: 1; display: flex; flex-direction: column;
}
.step-header {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 8px;
}
.step-name  { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 20px; }
.step-count { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted); }

.prog-bar {
    width: 100%; height: 5px;
    background: var(--border); border-radius: 99px;
    overflow: hidden; margin-bottom: 20px;
}
.prog-fill {
    height: 100%; background: var(--accent); border-radius: 99px;
    transition: width .4s ease;
}

/* ── STEP CARD — thumbnail inside ──
   card-media holds either the letter icon or a thumbnail photo */
.step-card {
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex; gap: 14px; align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}
.card-media {
    flex-shrink: 0;
    width: 64px; height: 64px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    background: var(--paper);
    display: flex; align-items: center; justify-content: center;
}
/* Thumbnail image inside card-media */
.card-thumb {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    border-radius: 12px;
}
/* Green done badge on thumbnail */
.card-thumb-badge {
    position: absolute; top: 4px; right: 4px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--success); color: #fff;
    font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.step-icon {
    width: 48px; height: 48px;
    background: var(--paper); border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'DM Mono', monospace; font-weight: 700;
    font-size: 13px; color: var(--muted);
}
.card-right { flex: 1; min-width: 0; }
.card-right h3 { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.card-right p  { font-size: 12px; color: #666; line-height: 1.4; margin-bottom: 6px; }
#step-card-filename {
    display: inline-block;
    font-family: 'DM Mono', monospace; font-size: 10px;
    background: var(--ink); color: #fff;
    padding: 2px 8px; border-radius: 4px;
}

/* ── CAPTURE ACTIONS ── */
.capture-actions {
    display: flex; flex-direction: column; gap: 12px;
    margin-bottom: 20px; flex-shrink: 0;
}

/* ── REQ STRIP ── */
.req-strip {
    display: flex; justify-content: center;
    gap: 16px; padding: 10px 0;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.req-item {
    font-size: 10px; color: var(--muted);
    font-weight: 700; text-transform: uppercase;
    letter-spacing: .6px;
}

/* ── ERROR ── */
.err-msg { color: var(--error); font-size: 13px; font-weight: 600; margin-top: 6px; min-height: 18px; }
.msg-box.error { color: var(--error); font-size: 13px; font-weight: 600; }

/* ── UTILS ── */
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ── SPINNER ── */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
    border-radius: 50%; animation: spin .7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════
   SCREEN 4 — EDITOR
   Topbar: single clean row, no wrapping
   Done button: fixed size, never shrinks
═══════════════════════════════════════════ */
.editor-screen {
    padding: 0; background: #111; align-items: center;
    /* Use full viewport height — no scroll on editor */
    height: 100dvh; max-height: 100dvh; overflow: hidden;
}

/* Topbar — single row, 3 columns: back | title | done */
.editor-topbar {
    width: 100%; max-width: 420px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 12px 16px;
    flex-shrink: 0;
    gap: 8px;
}
.editor-back-btn {
    background: none; border: none;
    color: rgba(255,255,255,.65); font-size: 14px; font-weight: 500;
    cursor: pointer; padding: 8px 4px;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap; text-align: left;
    justify-self: start;
}
.editor-title {
    font-family: 'Syne', sans-serif; font-weight: 700;
    font-size: 15px; color: #fff; letter-spacing: -.3px;
    text-align: center; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
/* Done button — fixed size, never shrinks on any screen */
.editor-done-btn {
    background: var(--accent); color: #fff; border: none;
    /* Fixed padding — does not scale with viewport */
    padding: 10px 20px;
    border-radius: 30px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px; font-weight: 700;
    cursor: pointer; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    min-width: 72px; /* guarantees "Done" never wraps */
    text-align: center;
    justify-self: end;
}

/* Square canvas */
.editor-canvas-wrap {
    position: relative;
    width: 100%; max-width: 420px;
    aspect-ratio: 1 / 1;
    overflow: hidden; background: #e8e8e8;
    touch-action: none;
    user-select: none; -webkit-user-select: none;
    cursor: grab; flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.1);
}
.editor-canvas-wrap:active { cursor: grabbing; }
#editor-canvas { position: absolute; top:0; left:0; display:block; }

/* ── Retake row — below canvas ── */
.editor-retake-row {
    width: 100%; max-width: 420px;
    display: flex; gap: 10px;
    padding: 10px 16px 0;
    flex-shrink: 0;
}
.editor-retake-btn {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 12px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 10px;
    color: rgba(255,255,255,.75);
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s;
    white-space: nowrap;
}
.editor-retake-btn:active { background: rgba(255,255,255,.16); }

/* ── Tab bar ── */
.editor-tabs {
    width: 100%; max-width: 420px;
    display: flex; gap: 0;
    margin-top: 10px;
    background: rgba(255,255,255,.06);
    border-radius: 12px; padding: 4px;
    flex-shrink: 0;
}
.editor-tab {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 5px;
    padding: 9px 4px;
    background: none; border: none; border-radius: 9px;
    color: #777;
    font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: background .2s, color .2s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.editor-tab.active { background: var(--accent); color: #fff; }

/* ── Tool panels ── */
.tool-panel {
    width: 100%; max-width: 420px;
    padding: 12px 16px;
    min-height: 70px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 10px;
    flex-shrink: 0;
}
.tool-hint { font-size: 11px; color: #666; text-align: center; line-height: 1.5; }

.zoom-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.zoom-icon { font-size: 20px; font-weight: 700; color: #777; width: 20px; text-align: center; }
.zoom-row input[type=range] { flex:1; accent-color: var(--accent); cursor:pointer; }
.zoom-val { font-family: 'DM Mono', monospace; font-size: 12px; color: #777; text-align: center; }

.rotate-row { display: flex; gap: 10px; width: 100%; }
.rotate-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 8px;
    background: rgba(255,255,255,.08);
    border: 1.5px solid rgba(255,255,255,.14);
    border-radius: 12px; color: #fff;
    font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 600;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: background .15s; white-space: nowrap;
}
.rotate-btn:active { background: rgba(255,255,255,.18); }

.editor-footer {
    font-family: 'DM Mono', monospace; font-size: 10px;
    color: #444; text-align: center; padding: 8px 16px 12px;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   SCREEN 5 — REVIEW & DOWNLOAD
═══════════════════════════════════════════ */
.gtin-chip {
    width: 100%; max-width: 420px;
    background: var(--ink); color: var(--paper);
    border-radius: 12px; padding: 14px 20px;
    display: flex; align-items: center; justify-content: space-between;
    margin: 12px 0 18px;
}
.gtin-chip .label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: #888; font-family: 'DM Mono', monospace;
}
.gtin-chip .value {
    font-family: 'DM Mono', monospace; font-size: 20px;
    font-weight: 500; letter-spacing: 2px;
}
.gallery {
    display: grid; grid-template-columns: repeat(2,1fr);
    gap: 12px; width: 100%; max-width: 420px; margin-bottom: 24px;
}
.gal-item {
    border-radius: 12px; overflow: hidden;
    border: 1.5px solid var(--border);
    background: var(--card); position: relative;
}
.gal-item img { width:100%; aspect-ratio:1; object-fit:cover; display:block; }
.gal-item .gal-label {
    padding: 7px 10px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted); font-family: 'DM Mono', monospace;
}
.gal-ok {
    position: absolute; top: 7px; right: 7px;
    background: var(--success); color: #fff;
    font-size: 10px; width: 20px; height: 20px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.gal-edit {
    position: absolute; bottom: 32px; right: 8px;
    background: var(--ink); color: #fff;
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    padding: 4px 10px; border-radius: 20px; cursor: pointer;
    letter-spacing: .5px;
    -webkit-tap-highlight-color: transparent;
}
.gal-edit:active { opacity: .8; }

/* ═══════════════════════════════════════════
   SCREEN 6 — PREVIEW BEFORE SAVE
   Topbar: grid layout same as editor
   Save button: fixed size, never shrinks
═══════════════════════════════════════════ */
.preview-screen {
    padding: 0; background: var(--paper); align-items: center;
}

/* Preview topbar — grid: back | title | save
   All three are fixed-size so they never wrap or squeeze */
.preview-topbar {
    width: 100%; max-width: 420px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1.5px solid var(--border);
    flex-shrink: 0;
    gap: 8px;
}
.preview-back-btn {
    background: none; border: none;
    color: var(--muted); font-size: 14px; font-weight: 500;
    cursor: pointer; padding: 8px 4px;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap; text-align: left;
    justify-self: start;
}
.preview-title {
    font-family: 'Syne', sans-serif; font-weight: 800;
    font-size: 16px; color: var(--ink);
    text-align: center; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}
/* Save button — fixed size, never shrinks */
.preview-save-btn {
    background: var(--accent); color: #fff; border: none;
    padding: 10px 20px;
    border-radius: 30px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px; font-weight: 700;
    cursor: pointer; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    min-width: 68px; /* guarantees "Save" never wraps */
    text-align: center;
    justify-self: end;
}

.preview-body {
    width: 100%; max-width: 420px;
    padding: 20px 0 32px;
    display: flex; flex-direction: column;
    align-items: center; gap: 12px;
    flex: 1;
}
.preview-img-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.07);
}
.preview-img-wrap img {
    width: 100%; height: 100%; object-fit: contain; display: block;
}
.preview-meta {
    font-family: 'DM Mono', monospace; font-size: 10px;
    color: var(--muted); text-align: center;
}

/* ═══════════════════════════════════════════
   TOASTS
═══════════════════════════════════════════ */
.toast-container {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
    z-index: 3000; display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    background: rgba(10,10,10,.92); color: #fff;
    padding: 11px 22px; border-radius: 30px;
    font-size: 13px; font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    animation: toastIn .28s cubic-bezier(.16,1,.3,1) both;
    backdrop-filter: blur(8px); white-space: nowrap;
}
@keyframes toastIn  { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.toast.fade-out { animation: toastOut .28s ease forwards; }
@keyframes toastOut { to { opacity:0; transform:translateY(-8px) scale(.92); } }