/* ============================================================
   Rodahl Kniver – designsystem
   Nordisk minimalisme · «Varm stein» · serif + sans · lyst
   ============================================================ */

/* Skriftene ligger på egen server (ikke Google Fonts), så besøkerens IP ikke sendes
   til Google. Variable filer med latinsk tegnsett (dekker æ, ø og å) fra Google Fonts. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/fraunces-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
}

:root {
  /* Farger */
  --bg: #f7f5f1;          /* varm off-white */
  --surface: #ffffff;
  --surface-2: #f0ede7;   /* dempet panel */
  --text: #1e1c1a;        /* kullsort */
  --text-muted: #6b655d;  /* varm grå */
  --border: #e4dfd6;      /* varm hårstrek */
  --border-strong: #d9d2c7;
  --accent: #9c6b3f;      /* messing / leire */
  --accent-press: #835634;
  --danger: #a6402f;
  --danger-press: #832f21;
  --moss: #4f6b4a;

  /* Typografi */
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Form */
  --radius: 10px;
  --radius-sm: 8px;
  --maxw: 1160px;
  --maxw-text: 720px;

  /* Spacing-skala */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  accent-color: var(--accent);
}

img { max-width: 100%; display: block; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.012em;
  margin: 0 0 var(--s3);
}
h1 { font-size: clamp(30px, 5vw, 44px); }
h2 { font-size: clamp(23px, 3vw, 30px); }
h3 { font-size: 20px; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--s5); }
.muted { color: var(--text-muted); }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar .container {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 64px; gap: var(--s4);
}
.brand {
  font-family: var(--font-serif);
  font-size: 22px; font-weight: 600; color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; opacity: .8; }
.topbar nav { display: flex; gap: var(--s2); align-items: center; }

/* ---- Hero (delt: tekst ved siden av innrammet bilde) ---- */
.hero { border-bottom: 1px solid var(--border); }
.hero-grid {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  align-items: center;
  gap: var(--s6);
  padding: var(--s7) var(--s5);
}
.hero-copy { max-width: 40ch; }
.hero-eyebrow {
  font-size: 12.5px; letter-spacing: 0.14em; text-transform: uppercase;
  margin: 0 0 var(--s3); font-weight: 600; color: var(--accent);
}
.hero-title {
  color: var(--text); margin: 0 0 var(--s3);
  font-size: clamp(34px, 4.4vw, 54px); font-weight: 600;
}
.hero-tagline {
  max-width: 38ch; margin: 0;
  font-size: clamp(15.5px, 2vw, 18px); line-height: 1.55;
  color: var(--text-muted);
}
.hero-media {
  aspect-ratio: 16 / 9; border-radius: var(--radius);
  background: var(--surface-2) center/contain no-repeat;
  border: 1px solid var(--border);
}

/* ---- Seksjonshode ---- */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: var(--s3);
  margin: var(--s7) 0 var(--s4);
}
.section-head h2 { margin: 0; }
/* Kategori- og typefilter stables høyrestilt sammen til høyre for «Utvalg». */
.section-head .filters { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); }
.section-head .filters .toolbar { justify-content: flex-end; }
.lead { font-size: 19px; color: var(--text-muted); max-width: var(--maxw-text); }

/* ---- Knapper ---- */
.btn {
  appearance: none; border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  font-family: var(--font-sans); font-size: 16px; font-weight: 550;
  letter-spacing: 0.01em;
  padding: 12px 22px; min-height: 48px;
  cursor: pointer; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  transition: background .15s ease, border-color .15s ease, transform .05s ease, opacity .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary:hover { background: var(--accent-press); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn-ghost { background: transparent; color: var(--text); padding-inline: 12px; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-press); }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---- Kort/flate ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---- Filter-chips ---- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  appearance: none; border: 1px solid var(--border-strong);
  background: transparent; color: var(--text-muted);
  border-radius: 999px; padding: 7px 16px; min-height: 38px;
  font-family: var(--font-sans); font-size: 14.5px; cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--text-muted); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--text); color: var(--surface); border-color: var(--text);
}

/* ---- Produktgrid (editorielt, kantfritt) ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: var(--s7) var(--s5);
  margin: var(--s5) 0 var(--s8);
}
.product-card { display: flex; flex-direction: column; color: var(--text); }
.product-card:hover { text-decoration: none; }
.product-card .thumb {
  aspect-ratio: 4 / 3; border-radius: var(--radius);
  background: var(--surface-2) center/contain no-repeat;
  display: grid; place-items: center;
  color: var(--text-muted); font-size: 14px;
  overflow: hidden; transition: transform .35s ease;
}
.product-card:hover .thumb { transform: scale(1.02); }
.product-card .body { padding: var(--s3) var(--s1) 0; display: flex; flex-direction: column; gap: 3px; }
.product-card .cat {
  font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
}
.product-card .name { font-family: var(--font-serif); font-weight: 500; font-size: 20px; }
.product-card:hover .name { color: var(--accent); }
.product-card .price { margin-top: var(--s1); font-size: 16px; font-weight: 550; }
.price.on-request { color: var(--accent); font-weight: 500; }

/* ---- Produktdetalj ---- */
.detail { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: var(--s7); margin: var(--s6) 0 var(--s8); }
.gallery .main {
  aspect-ratio: 4 / 3; border-radius: var(--radius);
  background: var(--surface-2) center/contain no-repeat;
  border: 1px solid var(--border);
}
.gallery .thumbs { display: flex; gap: var(--s2); margin-top: var(--s3); flex-wrap: wrap; }
.gallery .thumbs button {
  width: 68px; height: 68px; padding: 0;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2) center/contain no-repeat; cursor: pointer;
  transition: border-color .15s ease;
}
.gallery .thumbs button[aria-current="true"] { border-color: var(--accent); }

/* Hovedbilde: klikkbart + sveipbart */
.gallery .main-wrap { position: relative; }
.gallery .main { cursor: zoom-in; touch-action: pan-y; }
.gal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: rgba(255, 255, 255, 0.88);
  color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; padding: 0;
  box-shadow: var(--shadow);
}
.gal-nav:hover { background: #fff; }
.gal-nav.prev { left: 10px; }
.gal-nav.next { right: 10px; }

/* Lightbox – forstørret bilde med zoom */
.lightbox {
  position: fixed; inset: 0; background: rgba(15, 12, 10, 0.93); z-index: 100;
  display: none; align-items: center; justify-content: center;
  overflow: hidden; touch-action: none;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 92vw; max-height: 92vh; width: auto; height: auto; display: block;
  cursor: zoom-out; user-select: none; -webkit-user-drag: none; touch-action: none;
}
.lightbox-close {
  position: fixed; top: 14px; right: 16px; z-index: 101;
  width: 44px; height: 44px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18); color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.3); }
.lightbox-hint {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 101;
  background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 13px;
  padding: 7px 14px; border-radius: 999px; pointer-events: none; transition: opacity .4s ease;
}
.detail .info .cat {
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted);
}
.detail .info h1 { margin: var(--s2) 0 var(--s2); }

/* Spesifikasjonstabell */
#specs { width: 100%; border-collapse: collapse; margin: var(--s5) 0; font-size: 15.5px; }
#specs th, #specs td { text-align: left; padding: 11px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
#specs th { font-weight: 500; color: var(--text-muted); width: 42%; }

/* ---- Skjema ---- */
.field { margin-bottom: var(--s4); }
.field label { display: block; font-size: 14px; font-weight: 550; margin-bottom: 6px; }
.field .hint { color: var(--text-muted); font-size: 13.5px; margin-top: 5px; }
input, textarea, select {
  width: 100%; font-family: var(--font-sans); font-size: 16px;
  padding: 12px 14px; min-height: 48px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.required { color: var(--danger); }

/* Skjul datalist-pila (forslagslista virker fortsatt når man skriver) */
input[list]::-webkit-calendar-picker-indicator { display: none !important; }
input[list] { appearance: none; -webkit-appearance: none; }

/* Avkryssing/radio i messing-aksent */
input[type="checkbox"], input[type="radio"] {
  width: auto; min-height: auto; accent-color: var(--accent);
}

/* Nedtrekksmeny med egen, rolig pil (matcher paletten) */
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%236b655d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
}

/* Filopplasting som matcher resten */
input[type="file"] {
  padding: 10px 12px; font-size: 14.5px; color: var(--text-muted);
  background: var(--surface-2); border-style: dashed; cursor: pointer;
}
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 550; font-size: 14px;
  margin-right: 12px; padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
input[type="file"]::file-selector-button:hover {
  background: var(--surface-2); border-color: var(--text-muted);
}

/* ---- Merker / status ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-muted);
}
.badge.ny { background: #eef2ec; color: #3f5a3a; border-color: #d6e0d2; }
.badge.interessert { background: #e8eef3; color: #2f5670; border-color: #d3dde7; }
.badge.under_arbeid { background: #f6efe2; color: #8a6320; border-color: #e8dcc4; }
.badge.besvart { background: #eef2ec; color: #3f5a3a; border-color: #d2e0cd; }
.badge.solgt { background: #3f6b3a; color: #fff; border-color: #3f6b3a; }
.badge.lukket { background: #efece8; color: #6b655d; border-color: #e0dad1; }
.badge.hidden { background: #f6e9e6; color: #9a3526; border-color: #ecd2cc; }

/* ---- Notis ---- */
.notice {
  padding: 13px 15px; border-radius: var(--radius-sm); margin: var(--s3) 0;
  font-size: 15px; border: 1px solid var(--border-strong); background: var(--surface-2);
}
.notice.success { background: #eef2ec; border-color: #cfe0c9; color: #3a5635; }
.notice.error { background: #f7eae7; border-color: #ecccc5; color: #8f2e1f; }
.notice.info { background: #f2ede4; border-color: #e3d6bf; color: #7a5a23; }
.hidden { display: none !important; }

/* ---- Tom/lasting ---- */
.empty { text-align: center; color: var(--text-muted); padding: var(--s8) var(--s4); }
.spinner {
  width: 24px; height: 24px; margin: var(--s6) auto;
  border: 2.5px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Footer ---- */
footer {
  border-top: 1px solid var(--border); margin-top: var(--s8);
  padding: var(--s7) 0 var(--s8); color: var(--text-muted); font-size: 15px;
}
footer .container { display: flex; flex-wrap: wrap; gap: var(--s5); justify-content: space-between; }
footer strong { font-family: var(--font-serif); font-weight: 500; font-size: 17px; color: var(--text); }

/* ============================================================
   Admin
   ============================================================ */
.admin-tabs { display: flex; gap: var(--s4); margin: var(--s5) 0 var(--s4); border-bottom: 1px solid var(--border); }
.admin-tabs button {
  appearance: none; background: none; border: none; font: inherit; font-size: 16px;
  padding: 12px 2px; cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent; min-height: 48px;
}
.admin-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.list { display: flex; flex-direction: column; gap: var(--s2); margin: var(--s4) 0 var(--s8); }
.row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--s4); display: flex; gap: var(--s3); align-items: center;
}
.row .row-main { flex: 1; min-width: 0; }
.row .row-title { font-weight: 600; }
.row .row-sub { color: var(--text-muted); font-size: 14.5px; }
.row .row-actions { display: flex; gap: var(--s2); flex-shrink: 0; }
.row .row-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--surface-2) center/contain no-repeat; border: 1px solid var(--border);
}

/* ---- Datatabell (henvendelser) ---- */
.table-wrap { overflow-x: auto; margin: var(--s4) 0 var(--s8); -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.data-table th, .data-table td {
  text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap; vertical-align: middle;
}
.data-table thead th {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border-strong);
  user-select: none;
}
.th-sort {
  appearance: none; background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 6px;
  /* <button> arver ikke text-transform/letter-spacing – sett dem eksplisitt så
     de sorterbare overskriftene matcher den vanlige «Produkt»-overskriften. */
  text-transform: uppercase; letter-spacing: 0.04em;
}
.th-sort:hover { color: var(--text); }
.data-table th[aria-sort="ascending"], .data-table th[aria-sort="descending"] { color: var(--text); }
.data-table th[aria-sort="ascending"]  .th-sort::after { content: "▲"; font-size: 9px; }
.data-table th[aria-sort="descending"] .th-sort::after { content: "▼"; font-size: 9px; }
.data-table tbody tr { cursor: pointer; transition: background .12s ease; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td.col-order { font-variant-numeric: tabular-nums; font-weight: 600; }
.data-table td.col-name { white-space: normal; }
@media (max-width: 620px) {
  .data-table th.col-product, .data-table td.col-product { display: none; }
  .data-table { font-size: 13.5px; }
  .data-table th, .data-table td { padding: 11px 8px; }
}

/* ---- Hero-forhåndsvisning i admin (Forside-fanen) ---- */
.hero-preview {
  width: 100%; max-width: 360px; aspect-ratio: 16 / 9; margin-bottom: var(--s3);
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2) center/cover no-repeat;
  display: grid; place-items: center; color: var(--text-muted); font-size: 14px;
}

/* ---- «Om oss»-side ---- */
.about-body p {
  font-size: 17px; line-height: 1.7; color: var(--text);
  max-width: 64ch; margin: 0 0 var(--s4);
}
.about-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s3); margin: var(--s6) 0 var(--s7);
}
.about-tile {
  appearance: none; padding: 0; cursor: zoom-in;
  aspect-ratio: 4 / 3; border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2) center/cover no-repeat;
  transition: opacity .15s ease;
}
.about-tile:hover { opacity: .9; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,28,26,.42);
  display: grid; place-items: end center; z-index: 50;
}
.modal {
  background: var(--surface); width: 100%; max-width: 580px;
  max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: var(--s5);
  box-shadow: 0 -10px 50px rgba(0,0,0,.18);
}
.modal h2 { display: flex; justify-content: space-between; align-items: center; }
.modal .close { background: none; border: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--text-muted); padding: 4px 8px; }
.modal fieldset { border: 1px solid var(--border); border-radius: var(--radius); }
.modal legend { font-family: var(--font-sans); }

.login-wrap { max-width: 400px; margin: 12vh auto 0; }

/* ============================================================
   Responsivt
   ============================================================ */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .container { padding: 0 var(--s4); }
  .hero-grid { grid-template-columns: 1fr; gap: var(--s5); padding: var(--s6) var(--s4); }
  .hero-copy { max-width: none; }
  .detail { grid-template-columns: 1fr; gap: var(--s5); }
  .grid { gap: var(--s6) var(--s4); }
  .section-head { margin-top: var(--s6); }
  .row { flex-wrap: wrap; }
  .row .row-actions { width: 100%; }
  .row .row-actions .btn { flex: 1; }
}

@media (min-width: 640px) {
  .modal-backdrop { place-items: center; padding: var(--s4); }
  .modal { border-radius: 18px; }
}

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