/* ==========================================================================
   Fotodesigneren — fotolerret, alubilde, forstørrelse (nye.repix.no)
   Bygger på variablene i shop.css (--brand, --ink, --line, --radius …).
   Mobil først: alt stables, valgene ligger under bildet, og en klebrig
   kjøpslinje følger med nederst. Fra 1000 px: bildet til venstre, valgene
   til høyre (klebrige).
   ========================================================================== */

.fd { padding-bottom: 40px; }
/* [hidden] skal alltid vinne over display-regler under */
.fd [hidden], .fd-modal[hidden], .fd-sticky[hidden] { display: none !important; }

/* ── Topp ─────────────────────────────────────────────────────────────── */
.fd-head {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 32px;
    align-items: flex-end;
    justify-content: space-between;
    margin: 8px 0 22px;
}
.fd-kicker {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--brand);
    margin-bottom: 6px;
}
.fd-title { margin: 0 0 6px; font-size: clamp(1.7rem, 3.5vw, 2.4rem); }
.fd-lead { margin: 0; color: var(--muted); max-width: 60ch; }
.fd-head-price { text-align: right; }
.fd-head-price-label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.fd-head-price-value { font-size: 1.7rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.fd-head-price-note { font-size: .8rem; color: var(--muted); }

/* ── Rutenett ─────────────────────────────────────────────────────────── */
.fd-grid { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }

@media (min-width: 1000px) {
    .fd-grid { grid-template-columns: minmax(0, 1.55fr) minmax(360px, .95fr); gap: 32px; }
    .fd-panel { position: sticky; top: 92px; }
}

/* ── Scenen (bildet) ──────────────────────────────────────────────────── */
.fd-stage { min-width: 0; }

.fd-drop {
    position: relative;
    border: 2px dashed var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    min-height: 360px;
    display: grid;
    place-items: center;
    padding: 32px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    outline: none;
}
.fd-drop:hover, .fd-drop:focus-visible { border-color: var(--ink); }
.fd-drop.is-over { border-color: var(--brand); background: var(--brand-soft); }
.fd-drop.is-busy { cursor: progress; }
.fd-drop.is-busy .fd-drop-inner { opacity: .35; pointer-events: none; }
.fd-drop-icon { width: 64px; height: 64px; margin: 0 auto 14px; color: var(--brand); }
.fd-drop-icon svg { width: 100%; height: 100%; }
.fd-drop-title { font-size: 1.15rem; font-weight: 800; color: var(--ink); }
.fd-drop-sub { color: var(--muted); font-size: .9rem; margin: 6px 0 18px; }
.fd-drop-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.fd-progress {
    position: absolute;
    inset: auto 24px 24px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
}
.fd-progress-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.fd-progress-bar span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.fd-progress-text { font-size: .85rem; color: var(--muted); margin-top: 8px; }

/* Utsnitt */
.fd-crop { border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fff; overflow: hidden; }
.fd-crop-wrap {
    position: relative;
    background: #1b1f27;
    /* Høyde følger bredden, men aldri mer enn skjermen */
    height: min(62vw, 560px);
    min-height: 260px;
    touch-action: none;
}
@media (min-width: 1000px) { .fd-crop-wrap { height: min(48vw, 640px); } }
.fd-crop-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; pointer-events: none; }
.fd-crop-wrap.is-fit .cropper-container { display: none; }

.fd-fit-canvas { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; }
.fd-fit-overlay {
    position: absolute;
    pointer-events: none;
    border: 2px dashed rgba(226, 0, 26, .85);
    box-sizing: border-box;
}

/* Overlegg i Cropper-boksen: kantbrett (mørkt) + synlig flate (stiplet) */
.fd-fold-overlay {
    position: absolute;
    pointer-events: none;
    border: 2px dashed rgba(255, 255, 255, .9);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
    box-sizing: border-box;
    z-index: 2;
}
.fd-bleed-shade { position: absolute; pointer-events: none; background: rgba(0, 0, 0, .42); z-index: 1; }
/* Rammen tegnes som en kant rundt utsnittet */
.fd-frame-overlay { position: absolute; inset: 0; pointer-events: none; box-sizing: border-box; z-index: 3; }

.cropper-view-box, .cropper-face { outline: none; }
.cropper-modal { background: #1b1f27; opacity: .8; }
.cropper-line, .cropper-point { background-color: var(--brand); }
.cropper-point { width: 12px; height: 12px; opacity: .9; }
.cropper-point.point-se { width: 16px; height: 16px; }
.cropper-center { display: none; }

.fd-crop-help { padding: 10px 14px 0; font-size: .85rem; color: var(--muted); }
.fd-crop-bar {
    display: flex; flex-wrap: wrap; gap: 10px 16px;
    align-items: center; justify-content: space-between;
    padding: 10px 14px 12px;
}
.fd-crop-tools { display: flex; gap: 8px; }
.fd-tool {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px; border-radius: 8px;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer;
}
.fd-tool svg { width: 15px; height: 15px; }
.fd-tool:hover { border-color: var(--ink); }

/* Kvalitetsmåler */
.fd-quality { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); }
.fd-quality-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.fd-quality[data-level="great"] .fd-quality-dot { background: var(--success); }
.fd-quality[data-level="good"]  .fd-quality-dot { background: #4CAF50; }
.fd-quality[data-level="ok"]    .fd-quality-dot { background: #F5A524; }
.fd-quality[data-level="low"]   .fd-quality-dot { background: var(--danger); }
.fd-quality-value { color: var(--ink); }
.fd-quality[data-level="low"] .fd-quality-value { color: var(--danger); }
.fd-quality-hint { color: var(--muted); }

.fd-hint {
    margin: 0 14px 14px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--warn-soft);
    color: var(--warn);
    font-size: .85rem;
}

.fd-status {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: .9rem;
    font-weight: 600;
}
.fd-status.is-info { background: var(--surface); color: var(--text); font-weight: 500; }

/* ── Valgpanelet ──────────────────────────────────────────────────────── */
.fd-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 6px 0 0;
}
.fd-block { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.fd-block[hidden] { display: none; }
.fd-block-title {
    font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    color: var(--ink); margin-bottom: 10px;
    display: flex; align-items: baseline; gap: 8px;
}
.fd-optional { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: .78rem; }
.fd-block-help { font-size: .82rem; color: var(--muted); margin-top: 8px; }

/* Segmentert velger */
.fd-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface); border-radius: 10px; }
.fd-seg-btn {
    padding: 10px 8px; border: 0; border-radius: 8px; background: transparent;
    font: inherit; font-size: .92rem; font-weight: 700; color: var(--muted); cursor: pointer;
    transition: background .15s, color .15s;
    min-height: 44px;
}
.fd-seg-btn:hover { color: var(--ink); }
.fd-seg-btn.is-active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.fd-seg-btn[hidden] { display: none; }

/* Størrelse */
.fd-select {
    width: 100%; min-height: 48px; padding: 10px 40px 10px 14px;
    border: 1px solid var(--line); border-radius: 10px; background: #fff;
    font: inherit; font-size: 16px; font-weight: 600; color: var(--ink);
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23151A24' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.fd-select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.fd-orient { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.fd-orient[hidden] { display: none; }
.fd-orient-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; min-height: 48px;
    border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
    font: inherit; font-size: .9rem; font-weight: 600; color: var(--ink); cursor: pointer;
}
.fd-orient-btn.is-active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.fd-orient-shape { display: block; border: 2px solid currentColor; border-radius: 3px; }
.fd-orient-shape--land { width: 26px; height: 18px; }
.fd-orient-shape--port { width: 18px; height: 26px; }

/* Rammefarger */
.fd-swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.fd-swatch {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; min-height: 52px;
    border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
    font: inherit; text-align: left; color: var(--ink); cursor: pointer;
}
.fd-swatch[hidden] { display: none; }
.fd-swatch.is-active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.fd-swatch-chip { width: 26px; height: 26px; border-radius: 6px; flex: none; border: 1px solid rgba(0,0,0,.12); }
.fd-swatch-chip--none { background: repeating-linear-gradient(45deg, #fff 0 4px, var(--surface-2) 4px 8px); }
.fd-swatch-chip--black { background: #161616; }
.fd-swatch-chip--white { background: #F4F1EC; }
.fd-swatch-chip--oak { background: linear-gradient(135deg, #B8955D, #9E7A44); }
.fd-swatch-text { display: flex; flex-direction: column; line-height: 1.2; }
.fd-swatch-text span { font-size: .9rem; font-weight: 700; }
.fd-swatch-text small { font-size: .78rem; color: var(--muted); }

/* Papir */
.fd-papers { display: grid; gap: 8px; }
.fd-paper {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; min-height: 48px;
    border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
    font: inherit; text-align: left; color: var(--ink); cursor: pointer;
}
.fd-paper.is-active { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.fd-paper-name { font-size: .9rem; font-weight: 700; }
.fd-paper-price { font-size: .82rem; color: var(--muted); white-space: nowrap; }

/* Avkrysning */
.fd-check { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; }
.fd-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.fd-check-box {
    width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line); background: #fff; flex: none;
    display: grid; place-items: center;
}
.fd-check-box::after { content: ''; width: 12px; height: 7px; border: 2.5px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg) translateY(-1px); opacity: 0; }
.fd-check input:checked + .fd-check-box { background: var(--ink); border-color: var(--ink); }
.fd-check input:checked + .fd-check-box::after { opacity: 1; }
.fd-check input:focus-visible + .fd-check-box { outline: 2px solid var(--brand); outline-offset: 2px; }
.fd-check-text { font-weight: 700; font-size: .95rem; }
.fd-check-text small { font-weight: 600; color: var(--muted); margin-left: 4px; }

/* Kjøp */
.fd-buy { padding: 18px 20px 20px; background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.fd-price { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fd-price-now { font-size: 1.9rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.fd-price.is-sale .fd-price-now { color: var(--brand); }
.fd-price-was { font-size: 1rem; color: var(--muted); }
.fd-price-note { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.fd-price-lines { list-style: none; margin: 8px 0 0; padding: 0; font-size: .82rem; color: var(--muted); }
.fd-price-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.fd-price-lines li span:last-child { color: var(--ink); font-weight: 600; }
.fd-buy-row { display: flex; gap: 10px; margin: 14px 0 10px; }
.fd-qty { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; background: #fff; overflow: hidden; }
.fd-qty-btn { width: 44px; border: 0; background: transparent; font-size: 1.2rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.fd-qty-btn:hover { background: var(--surface-2); }
.fd-qty input { width: 56px; border: 0; text-align: center; font: inherit; font-size: 16px; font-weight: 700; color: var(--ink); -moz-appearance: textfield; }
.fd-qty input::-webkit-outer-spin-button, .fd-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.fd-preview-btn { flex: 1; min-height: 48px; }
.fd-add { min-height: 52px; font-size: 1rem; }
.fd-add:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
.fd-add.is-busy { pointer-events: none; }
.fd-buy-note { font-size: .8rem; color: var(--muted); margin-top: 12px; line-height: 1.5; }

/* ── Info-kort ────────────────────────────────────────────────────────── */
.fd-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 36px; }
.fd-info-card { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.fd-info-card summary { list-style: none; cursor: pointer; padding: 16px; display: grid; gap: 4px; }
.fd-info-card summary::-webkit-details-marker { display: none; }
.fd-info-card summary img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; margin-bottom: 6px; }
.fd-info-title { font-weight: 800; color: var(--ink); }
.fd-info-short { font-size: .88rem; color: var(--muted); }
.fd-info-more { font-size: .8rem; font-weight: 700; color: var(--brand); margin-top: 4px; }
.fd-info-card[open] .fd-info-more { display: none; }
.fd-info-body { padding: 0 16px 16px; font-size: .92rem; }
.fd-info-body p { margin: 0 0 .7em; }
.fd-info-tip { padding: 10px 12px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; font-size: .85rem; }

.fd-desc { display: grid; gap: 24px; margin-top: 36px; align-items: start; }
@media (min-width: 800px) { .fd-desc { grid-template-columns: 1.4fr 1fr; } }
.fd-desc-text { font-size: 1rem; max-width: 70ch; }
.fd-desc-img { border-radius: var(--radius-lg); width: 100%; object-fit: cover; }

/* ── Klebrig kjøpslinje (mobil) ───────────────────────────────────────── */
.fd-sticky {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(21,26,36,.08);
}
.fd-sticky[hidden] { display: none; }
.fd-sticky-price { display: flex; flex-direction: column; line-height: 1.1; }
.fd-sticky-price strong { font-size: 1.15rem; color: var(--ink); }
.fd-sticky-price small { font-size: .75rem; color: var(--muted); }
@media (min-width: 1000px) { .fd-sticky { display: none !important; } }
body.fd-has-sticky { padding-bottom: 80px; }

/* ── Modaler ──────────────────────────────────────────────────────────── */
.fd-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; }
.fd-modal[hidden] { display: none; }
.fd-modal-backdrop { position: absolute; inset: 0; background: rgba(21, 26, 36, .6); }
.fd-modal-card {
    position: relative; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow);
    width: min(1080px, 100%); max-height: min(92dvh, 92vh); overflow: auto;
    display: grid; grid-template-columns: 1fr;
}
.fd-modal--sm .fd-modal-card { width: min(440px, 100%); }
@media (min-width: 860px) { .fd-modal:not(.fd-modal--sm) .fd-modal-card { grid-template-columns: 1.5fr 1fr; } }
.fd-modal-close {
    position: absolute; top: 10px; right: 10px; z-index: 2;
    width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; box-shadow: var(--shadow-sm);
    font-size: 1.5rem; line-height: 1; color: var(--ink); cursor: pointer;
}
.fd-modal-stage {
    display: grid; place-items: center; padding: 40px 28px;
    background: linear-gradient(180deg, #F3F4F6, #E6E8EC);
    min-height: 320px;
}
.fd-modal-frame { position: relative; display: inline-block; box-shadow: 0 18px 40px rgba(21,26,36,.28), 0 2px 6px rgba(21,26,36,.18); background: #fff; }
.fd-modal-frame canvas { display: block; max-width: 100%; max-height: 55vh; max-height: 55dvh; }
.fd-modal-side { padding: 28px 24px; }
.fd-modal-title { font-size: 1.35rem; margin: 0 0 12px; }
.fd-modal-spec { list-style: none; margin: 0 0 16px; padding: 0; font-size: .9rem; }
.fd-modal-spec li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.fd-modal-spec li span:first-child { color: var(--muted); }
.fd-modal-price { font-size: 1.6rem; font-weight: 800; color: var(--ink); margin-bottom: 16px; }
.fd-modal-price small { font-size: .85rem; font-weight: 600; color: var(--muted); }
.fd-modal-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.fd-modal-actions .btn { flex: 1; min-height: 48px; }
.fd-modal-actions--col { flex-direction: column; }

.fd-qr, .fd-done { padding: 28px 24px; text-align: center; }
.fd-qr p, .fd-done p { color: var(--muted); font-size: .92rem; }
.fd-qr-code { display: grid; place-items: center; min-height: 232px; margin: 16px auto; }
.fd-qr-code img, .fd-qr-code canvas { border-radius: 8px; border: 1px solid var(--line); padding: 8px; background: #fff; }
.fd-qr-status { font-size: .88rem; font-weight: 600; color: var(--ink); }
.fd-qr-status.is-ok { color: var(--success); }
.fd-qr-link { display: inline-block; margin-top: 10px; font-size: .85rem; color: var(--brand); text-decoration: underline; }
.fd-done-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: grid; place-items: center; margin: 0 auto 12px; }
.fd-done-icon svg { width: 30px; height: 30px; }

.fd-spinner {
    width: 28px; height: 28px; border-radius: 50%;
    border: 3px solid var(--line); border-top-color: var(--brand);
    animation: fd-spin .8s linear infinite;
}
@keyframes fd-spin { to { transform: rotate(360deg); } }

body.fd-modal-open { overflow: hidden; }
