/* styles.css — Mariannes fakturaprogram.
   Uttrykk: rolig skandinavisk "premium" — varm papirbakgrunn, kjølig petrol-aksent,
   ekte typografi (Fraunces display + Schibsted Grotesk), dybde og dempet bevegelse.
   Mobil-først. Previewet (.a4) beholder Helvetica for WYSIWYG mot PDF-en. */

/* ---------- Fonter (selvhostet -> offline) ---------- */
@font-face { font-family: 'Schibsted Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/schibsted-400.woff2') format('woff2'); }
@font-face { font-family: 'Schibsted Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/schibsted-500.woff2') format('woff2'); }
@font-face { font-family: 'Schibsted Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/schibsted-700.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/fraunces-600.woff2') format('woff2'); }

:root {
  --accent: #33536B;
  --accent-deep: #21384a;
  --accent-bright: #5a86a6;
  --accent-tint: #e9eff3;
  --gold: #b98a4b;
  --ink: #1c2a33;
  --muted: #61707b;
  --faint: #93a1ab;
  --line: #e4e1da;
  --line-strong: #d4d0c6;
  --bg: #f4f1ec;
  --bg-2: #efece5;
  --card: #ffffff;
  --danger: #b8392f;
  --ok: #2e7d4f;
  --radius: 16px;
  --radius-sm: 12px;
  --tap: 54px;
  --maxw: 580px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-ui: 'Schibsted Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --shadow-sm: 0 1px 2px rgba(28,42,51,.06), 0 1px 3px rgba(28,42,51,.05);
  --shadow-md: 0 2px 6px rgba(28,42,51,.06), 0 14px 30px -18px rgba(28,42,51,.30);
  --shadow-lg: 0 18px 50px -20px rgba(28,42,51,.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  background-image:
    radial-gradient(120% 80% at 100% 0%, rgba(51,83,107,.05) 0%, rgba(51,83,107,0) 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 17px; line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { padding-bottom: calc(var(--tap) + 38px + var(--safe-bottom)); }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 20;
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 18px 16px;
  background:
    radial-gradient(140% 120% at 88% -20%, rgba(120,160,185,.45) 0%, rgba(120,160,185,0) 50%),
    linear-gradient(150deg, #3a5d77 0%, var(--accent) 45%, var(--accent-deep) 100%);
  box-shadow: 0 10px 30px -16px rgba(33,56,74,.7);
}
.app-header__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: var(--maxw); margin: 0 auto; }
.app-title {
  font-family: var(--font-display); font-weight: 600; font-size: 20px; margin: 0;
  letter-spacing: .1px; line-height: 1.1;
}
.link-btn {
  background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px; padding: 9px 16px; font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; backdrop-filter: blur(4px); transition: background .15s ease;
}
.link-btn:active { background: rgba(255,255,255,.28); }

.progress { max-width: var(--maxw); margin: 16px auto 2px; display: flex; align-items: center; gap: 12px; }
.progress__bar { flex: 1; height: 5px; background: rgba(255,255,255,.22); border-radius: 999px; overflow: hidden; }
.progress__fill {
  height: 100%; width: 16.6%; border-radius: 999px;
  background: linear-gradient(90deg, #cfe0ea, #ffffff);
  box-shadow: 0 0 12px rgba(255,255,255,.6);
  transition: width .45s cubic-bezier(.22,.61,.36,1);
}
.progress__label { font-size: 12.5px; font-weight: 600; letter-spacing: .3px; white-space: nowrap; opacity: .92; }

/* ---------- Main / steps ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 24px 18px 8px; }
.step { animation: stepIn .42s cubic-bezier(.22,.61,.36,1) both; }
.step > * { animation: riseIn .5s cubic-bezier(.22,.61,.36,1) both; }
.step > *:nth-child(2) { animation-delay: .05s; }
.step > *:nth-child(3) { animation-delay: .10s; }
.step > *:nth-child(4) { animation-delay: .15s; }
.step > *:nth-child(5) { animation-delay: .20s; }
.step > *:nth-child(6) { animation-delay: .24s; }
.step > *:nth-child(7) { animation-delay: .28s; }
@keyframes stepIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.step__title {
  font-family: var(--font-display); font-weight: 600; font-size: 30px; line-height: 1.08;
  letter-spacing: -.2px; margin: 2px 0 22px; color: var(--ink);
}
.step__title::after {
  content: ""; display: block; width: 42px; height: 3px; margin-top: 12px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

/* ---------- Felter ---------- */
.field { display: block; margin-bottom: 18px; }
.field__label {
  display: block; font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px;
}
.field__input, select.field__input {
  width: 100%; min-height: var(--tap); padding: 13px 16px;
  font: inherit; font-size: 17px; color: var(--ink); background: var(--card);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  appearance: none; -webkit-appearance: none;
  box-shadow: var(--shadow-sm); transition: border-color .16s ease, box-shadow .16s ease;
}
.field__input::placeholder { color: var(--faint); }
.field__input:focus, select.field__input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(51,83,107,.14), var(--shadow-sm);
}
select.field__input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2333536B' stroke-width='2.2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 15px center; padding-right: 42px;
}
/* Brønnøysund-forslag under navnefeltet */
.suggest-wrap { position: relative; }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); overflow: hidden; max-height: 320px; overflow-y: auto;
  animation: riseIn .22s ease both;
}
.suggest__head { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--faint); padding: 11px 14px 6px; }
.suggest__item { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; background: transparent; border: none; border-top: 1px solid var(--line); padding: 12px 14px; cursor: pointer; font: inherit; }
.suggest__item:active { background: var(--accent-tint); }
.suggest__name { font-weight: 600; color: var(--ink); }
.suggest__addr { font-size: 13px; color: var(--muted); }

.field-row { display: flex; gap: 12px; }
.field--postnr { flex: 0 0 116px; }
.field--sted { flex: 1; }
.error { color: var(--danger); font-size: 14px; font-weight: 500; margin: -8px 0 14px; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: center; justify-content: center; gap: 30px; margin: 14px 0 28px; }
.stepper__btn {
  width: 66px; height: 66px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--card); color: var(--accent); font-size: 32px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md); transition: transform .12s ease, color .12s ease, background .12s ease;
}
.stepper__btn:active { transform: scale(.92); background: var(--accent); color: #fff; }
.stepper__btn:disabled { opacity: .35; box-shadow: var(--shadow-sm); }
.stepper__value { font-family: var(--font-display); font-weight: 600; font-size: 46px; min-width: 64px; text-align: center; color: var(--ink); }
.horse-names .field { margin-bottom: 14px; }

/* ---------- Beløp ---------- */
.same-price { display: flex; gap: 10px; align-items: stretch; margin-bottom: 20px; }
.same-price .field__input { flex: 1; margin: 0; }
.same-price .btn { white-space: nowrap; flex: 0 0 auto; }
.price-rows .price-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 14px; box-shadow: var(--shadow-sm);
}
.price-row__name { flex: 1; font-weight: 600; color: var(--ink); }
.price-row__input { flex: 0 0 132px; min-height: 46px; margin: 0; box-shadow: none; }
.live-sum {
  margin-top: 22px; font-size: 17px; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1.5px solid var(--line-strong); padding-top: 16px;
}
.live-sum strong { font-family: var(--font-display); font-weight: 600; font-size: 26px; color: var(--accent); }

/* ---------- Fieldset / radios / disclosure ---------- */
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 16px 14px; margin: 0 0 18px; background: var(--card); box-shadow: var(--shadow-sm); }
.fieldset__legend { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; padding: 0 6px; }
.radio, .checkbox { display: flex; align-items: center; gap: 14px; min-height: 50px; font-size: 16px; cursor: pointer; }
.radio + .radio { border-top: 1px solid var(--line); }
.radio input, .checkbox input { width: 22px; height: 22px; accent-color: var(--accent); }
.disclosure { border: 1px solid var(--line); border-radius: var(--radius); padding: 2px 16px; margin-bottom: 14px; background: var(--card); box-shadow: var(--shadow-sm); }
.disclosure summary { font-weight: 600; padding: 14px 0; cursor: pointer; list-style: none; color: var(--ink); }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::after { content: "+"; float: right; color: var(--accent); font-size: 20px; line-height: 1; }
.disclosure[open] summary::after { content: "–"; }

/* ---------- Knapper ---------- */
.btn {
  min-height: var(--tap); padding: 0 22px; border-radius: var(--radius-sm); border: none;
  font: inherit; font-size: 17px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, box-shadow .16s ease, background .16s ease;
}
.btn:active { transform: scale(.975); }
.btn--primary {
  color: #fff; background: linear-gradient(180deg, #3d617c 0%, var(--accent) 100%);
  box-shadow: 0 10px 24px -12px rgba(33,56,74,.85), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn--primary:active { background: linear-gradient(180deg, #335570, var(--accent-deep)); }
.btn--primary:disabled { opacity: .5; box-shadow: none; }
.btn--secondary { background: var(--accent-tint); color: var(--accent); }
.btn--secondary:active { background: #dde7ed; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:active { background: rgba(28,42,51,.05); }

/* ---------- Bunnlinje ---------- */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 12px; padding: 14px 18px calc(14px + var(--safe-bottom));
  background: rgba(247,245,240,.86); backdrop-filter: blur(14px) saturate(1.3);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 30px -22px rgba(28,42,51,.5);
}
.bottom-bar .btn { flex: 1; }
.bottom-bar #nav-back { flex: 0 0 36%; }

/* ---------- Preview ---------- */
.step--preview { padding-bottom: 0; }
.zoom-controls { display: inline-flex; gap: 2px; margin: 0 auto 12px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm); }
.zoom-controls { display: flex; width: max-content; }
.step--preview .zoom-controls { margin-left: auto; margin-right: auto; }
.zoom-btn { min-width: 54px; height: 42px; border-radius: 999px; border: none; background: transparent; color: var(--accent); font: inherit; font-size: 22px; font-weight: 600; cursor: pointer; transition: background .12s ease; }
.zoom-btn:active { background: var(--accent-tint); }
.zoom-btn--wide { padding: 0 18px; font-size: 15px; }
.preview-viewport {
  position: relative; height: 56vh; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(160deg, #e8edf1, #dce3e9);
  border: 1px solid var(--line); box-shadow: inset 0 2px 14px rgba(28,42,51,.10); touch-action: none;
}

/* A4-ark som speiler PDF-en (mm/pt). Egen skrift = Helvetica for WYSIWYG. */
.a4 {
  position: absolute; top: 0; left: 0; width: 210mm; height: 297mm; background: #fff;
  transform-origin: 0 0; box-shadow: 0 8px 30px rgba(28,42,51,.28);
  font-family: Helvetica, Arial, sans-serif;
}
.a4 .op-text { position: absolute; line-height: 1; white-space: nowrap; }
.a4 .op-line { position: absolute; }
.a4 .op-rect { position: absolute; }
.a4 { overflow: hidden; }
.a4 .edit-zone { position: absolute; background: transparent; border: 1px dashed transparent; border-radius: 4px; cursor: pointer; padding: 0; margin: 0; transition: background .12s ease; }
.a4 .edit-zone:hover, .a4 .edit-zone:active { background: rgba(51,83,107,.09); border-color: rgba(51,83,107,.4); }

/* ---------- Send / status ---------- */
.send-summary { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow-md); }
.send-summary dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; }
.send-summary dt { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; align-self: center; }
.send-summary dd { margin: 0; font-weight: 600; text-align: right; align-self: center; }
.send-status { padding: 20px; border-radius: var(--radius); font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 18px; box-shadow: var(--shadow-sm); animation: riseIn .4s ease both; }
.send-status--ok { background: #e7f3ec; color: var(--ok); border: 1px solid #cfe6d8; }
.send-status--info { background: var(--accent-tint); color: var(--accent); border: 1px solid #d6e2ea; }
.post-send { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Modal / overlay ---------- */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: rgba(28,42,51,.55); padding: 22px; backdrop-filter: blur(3px); animation: stepIn .25s ease both; }
.modal__card { background: var(--card); border-radius: 20px; padding: 28px 24px; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-lg); animation: popIn .34s cubic-bezier(.22,.61,.36,1) both; }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal__card h2 { font-family: var(--font-display); font-weight: 600; margin: 0; font-size: 23px; }
.modal__card p { margin: 0 0 6px; color: var(--muted); }

.overlay { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; animation: stepIn .2s ease both; }
.overlay__header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top,0px) + 16px) 18px 16px; color: #fff; background: linear-gradient(150deg, #3a5d77, var(--accent-deep)); }
.overlay__header h2 { font-family: var(--font-display); font-weight: 600; margin: 0; font-size: 20px; }
.log-list { max-width: var(--maxw); margin: 0 auto; padding: 16px 18px 44px; }
.log-item { width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 14px; box-shadow: var(--shadow-sm); transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
.log-item:active { transform: scale(.99); border-color: var(--accent); box-shadow: var(--shadow-md); }
.log-item__main { display: flex; flex-direction: column; gap: 3px; }
.log-item__nr { font-weight: 700; color: var(--accent); }
.log-item__cust { font-size: 15px; }
.log-item__meta { font-size: 13px; color: var(--muted); }
.log-item__sum { font-family: var(--font-display); font-weight: 600; font-size: 18px; white-space: nowrap; }
.log-empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tap) + 32px + var(--safe-bottom)); z-index: 50;
  background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 999px;
  font-size: 15px; font-weight: 500; max-width: 90%; text-align: center;
  box-shadow: var(--shadow-lg); animation: popIn .3s ease both;
}

[hidden] { display: none !important; }

@media (min-width: 600px) { .preview-viewport { height: 66vh; } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
