/* Quiltfoto
   Idé: arbeidsflaten er en grønn skjærematte, aksenten er gul som markeringene
   på en quiltelinjal. Alt annet holdes rolig og nøkternt. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/SchibstedGrotesk-var.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --ink: #1d211f;
  --muted: #5f6a64;
  --ground: #eceeea;
  --paper: #ffffff;
  --line: #d6dad3;
  --line-strong: #b9c0b8;
  --mat: #2c5545;
  --mat-deep: #234638;
  --mat-text: #e6efe9;
  --ruler: #f4c430;
  --pin: #c0392b;
  --r-panel: 10px;
  --r-ctrl: 6px;
  --font: "Schibsted Grotesk", "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- topplinje ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 12px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 19px; font-weight: 800; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none;
}
.steps { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { counter-increment: step; }
.steps button {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border: 0; border-radius: 999px;
  background: none; color: var(--muted); font-size: 14px; cursor: pointer;
}
.steps button::before {
  content: counter(step);
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--line-strong); font-size: 12px; font-weight: 700;
}
.steps li.current button { color: var(--ink); font-weight: 600; }
.steps li.current button::before { background: var(--ruler); border-color: var(--ink); }
.steps li.done button::before { content: "✓"; background: var(--ink); border-color: var(--ink); color: #fff; }
.steps button:hover { background: var(--ground); }

/* ---------- oppsett ---------- */
.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr) 350px;
  gap: 18px; align-items: start;
  max-width: 1720px; margin: 0 auto; padding: 18px 24px 48px;
}
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); }
.settings, .recipe { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }

/* ---------- innstillinger ---------- */
.group { padding: 16px 18px 18px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h2 { font-size: 15px; font-weight: 750; margin-bottom: 4px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.field { margin-top: 14px; }
.field > label, .lbl {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 13.5px; color: var(--muted); margin-bottom: 6px;
}
.field output { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.hint { font-size: 12.5px; line-height: 1.45; color: var(--muted); margin: 6px 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 > .field { min-width: 0; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--line-strong); border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 3px; background: var(--line-strong); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 22px; margin-top: -9.5px;
  background: var(--ruler); border: 1.5px solid var(--ink); border-radius: 3px;
}
input[type="range"]::-moz-range-thumb { width: 10px; height: 20px; background: var(--ruler); border: 1.5px solid var(--ink); border-radius: 3px; }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px rgba(29, 33, 31, .25); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px rgba(29, 33, 31, .25); }

select, .num {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--r-ctrl); background: var(--paper);
}
select { padding: 7px 9px; }
.num { display: flex; align-items: stretch; overflow: hidden; }
.num:focus-within { border-color: var(--ink); }
.num input { flex: 1; width: 100%; min-width: 0; border: 0; padding: 7px 9px; background: transparent; }
.num input:focus { outline: none; }
.num span { display: grid; place-items: center; padding: 0 9px; font-size: 13px; color: var(--muted); background: var(--ground); }
.num.narrow { width: 50%; }

.seg { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r-ctrl); }
.seg label {
  flex: 1; text-align: center; padding: 6px 4px; border-radius: 4px;
  font-size: 13px; color: var(--muted); cursor: pointer; user-select: none;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 1px; }

.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--ink); width: 16px; height: 16px; }
.check small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; }

.custom-list { display: flex; flex-wrap: wrap; gap: 6px; }
.cc { position: relative; }
.cc-x {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12px; line-height: 18px;
  cursor: pointer; opacity: 0; transition: opacity .12s;
}
.cc:hover .cc-x, .cc-x:focus-visible { opacity: 1; }
.row-btns { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- knapper ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--ink); border-radius: var(--r-ctrl);
  background: var(--paper); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--ground); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.quiet { border-color: var(--line-strong); }
.btn.primary { background: var(--ruler); border-color: var(--ink); color: var(--ink); }
.btn.primary:hover { background: #ffd34f; }
.btn.big { padding: 12px 24px; font-size: 16px; }
.btn.block { width: 100%; }
.btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.link { border: 0; padding: 0; background: none; color: var(--ink); font-size: 13px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.group > .link { margin-top: 12px; }

/* ---------- skjærematte ---------- */
.mat {
  background-color: var(--mat);
  background-image:
    linear-gradient(45deg, transparent calc(50% - .6px), rgba(255, 255, 255, .13) 50%, transparent calc(50% + .6px)),
    linear-gradient(rgba(255, 255, 255, .17) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .17) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .055) 1px, transparent 1px);
  background-size: 100% 100%, 60px 60px, 60px 60px, 12px 12px, 12px 12px;
  background-position: 0 0, -1px -1px, -1px -1px, -1px -1px, -1px -1px;
}

.workspace { position: relative; min-width: 0; }
.dropzone {
  display: grid; place-items: center; min-height: min(640px, calc(100vh - 110px));
  padding: 48px 24px; border-radius: var(--r-panel); color: var(--mat-text);
  text-align: center; cursor: pointer; outline-offset: -10px;
}
.dropzone:focus-visible { outline: 3px solid var(--ruler); outline-offset: -10px; }
.workspace.over .dropzone { outline: 3px dashed var(--ruler); }
.drop-inner { max-width: 560px; }
.drop-art { width: 200px; height: auto; display: block; margin: 0 auto 28px; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35)); }
.dropzone h1 { text-wrap: balance; font-size: clamp(28px, 3vw, 40px); font-weight: 800; letter-spacing: -0.02em; color: #fff; }
.dropzone .lead { margin: 12px 0 16px; font-size: 17px; }
.dropzone .fine { margin: 22px 0 0; font-size: 13px; opacity: .75; }

/* ---------- redigering ---------- */
.editor { overflow: hidden; }
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; }
.tab {
  padding: 7px 12px; border: 0; border-bottom: 3px solid transparent; background: none;
  color: var(--muted); font-weight: 600; cursor: pointer;
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ruler); }
.tools { display: flex; gap: 6px; flex-wrap: wrap; }
.canvas-wrap { position: relative; display: flex; justify-content: center; align-items: flex-start; padding: 24px; overflow: auto; min-height: 220px; }
#canvas { display: block; flex: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 24px rgba(0, 0, 0, .28); }
#canvas.painting { cursor: crosshair; touch-action: none; }
.tooltip {
  position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none;
  padding: 6px 10px; border-radius: 4px; background: var(--ruler); color: var(--ink);
  border: 1px solid var(--ink); font-size: 13px; line-height: 1.35; white-space: nowrap;
}
.tooltip small { display: block; color: #4a4320; }
.tt-sw { display: inline-block; width: 11px; height: 11px; margin-right: 6px; border: 1px solid var(--ink); vertical-align: -1px; }
.note { margin: 0; padding: 9px 16px; font-size: 13.5px; background: #fff6d6; border-bottom: 1px solid var(--line); }
.note.warn { background: #fbebe8; }

.fabrics { padding: 14px 16px 18px; }
.fabrics .group-head { margin-bottom: 10px; flex-wrap: wrap; }
.fabrics h2 { font-size: 15px; font-weight: 750; }
.fabric-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.fabric {
  display: grid; grid-template-columns: 32px 16px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 5px 8px 5px 5px; border: 1px solid var(--line); border-radius: var(--r-ctrl); cursor: pointer;
}
.fabric:hover { border-color: var(--line-strong); }
.fabric.brush { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--ruler); }
.flabel { font-weight: 800; }
.fname { min-width: 0; padding: 3px 5px; border: 1px solid transparent; border-radius: 4px; background: none; }
.fname:hover { border-color: var(--line); }
.fname:focus { border-color: var(--ink); outline: none; }
.fcount { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.swatch {
  position: relative; display: block; width: 32px; height: 32px; border-radius: 4px; overflow: hidden;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); cursor: pointer;
}
.swatch.sm { width: 30px; height: 30px; }
.swatch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.swatch:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }

.busy {
  position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: rgba(236, 238, 234, .45); font-weight: 650; border-radius: var(--r-panel);
}
.busy span:last-child { padding: 6px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--ink); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- oppskrift ---------- */
.recipe { padding: 0 0 18px; }
.recipe-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.recipe-head h2 { font-size: 15px; font-weight: 750; margin-bottom: 8px; }
.title-input { width: 100%; padding: 6px 0; border: 0; border-bottom: 1.5px solid var(--line-strong); font-size: 19px; font-weight: 700; background: none; }
.title-input:focus { outline: none; border-bottom-color: var(--ink); }
.recipe h3 { margin: 18px 18px 0; font-size: 14px; font-weight: 750; }
.recipe > .hint { margin: 4px 18px 8px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 1px 0 0; font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.25; }
.facts dd small { display: block; margin-top: 2px; font-size: 12px; font-weight: 400; color: var(--muted); }
#warnings p { margin: 12px 18px 0; padding: 8px 10px; font-size: 13px; background: #fbebe8; border-left: 3px solid var(--pin); }

.ftable { width: calc(100% - 36px); margin: 0 18px; border-collapse: collapse; font-size: 13.5px; }
.ftable th { padding: 6px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; border-bottom: 1px solid var(--line-strong); }
.ftable td { padding: 7px 4px; vertical-align: top; border-bottom: 1px solid var(--line); }
.ftable .amt { text-align: right; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.ftable .sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.sw { display: inline-block; width: 13px; height: 13px; margin-right: 4px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); vertical-align: -2px; }

details { margin: 16px 18px 0; border-top: 1px solid var(--line); }
summary { padding: 12px 0 4px; font-size: 14px; font-weight: 750; cursor: pointer; }
.rows-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 360px; overflow: auto; font-size: 12.5px; }
.rows-list li { display: flex; gap: 6px; align-items: baseline; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.rows-list .rn { flex: none; width: 26px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rows-list .chips { display: flex; flex-wrap: wrap; gap: 3px; }
.chip { padding: 0 5px; border-radius: 3px; font-weight: 700; background: var(--c); color: var(--ink2, #1d211f); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
#btn-print { width: calc(100% - 36px); margin: 18px 18px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px)); padding: 10px 16px; border-radius: var(--r-ctrl);
  background: var(--ink); color: #fff; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}

/* Før oppskriften finnes, får arbeidsflaten hele bredden. */
@media (min-width: 861px) {
  .layout:has(#recipe-panel[hidden]) .workspace { grid-column: 2 / -1; }
}

/* ---------- mindre skjermer ---------- */
@media (max-width: 1320px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr); }
  .recipe { grid-column: 2; position: static; max-height: none; }
}
@media (max-width: 860px) {
  .topbar { padding: 10px 14px; }
  .steps { display: none; }
  .layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .workspace { order: -1; }
  .settings, .recipe { position: static; max-height: none; grid-column: auto; }
  .canvas-wrap { padding: 12px; }
  .dropzone { min-height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .cc-x { transition: none; }
}
