/* =========================================================
   Hamar Tak — 3D-huset
   Brukes på forsiden, Nytt tak, Takfornying og Tak- og fasadevask.
   Uten JavaScript eller 3D-støtte skjules huset, og teksten står igjen.
   ========================================================= */

.tak3d-only, .tak3d-stage { display: none; }
.js .tak3d-only, .js .tak3d-stage { display: block; }
.no-tak3d .tak3d-only, .no-tak3d .tak3d-stage { display: none; }

/* ---------- Scenen huset står på ---------- */
.tak3d-stage {
  position: relative; overflow: hidden; isolation: isolate;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(110% 85% at 80% 4%, rgba(208, 88, 72, 0.36), rgba(208, 88, 72, 0) 60%),
    radial-gradient(90% 70% at 12% 100%, rgba(126, 156, 196, 0.18), rgba(126, 156, 196, 0) 62%),
    linear-gradient(180deg, #262d32 0%, #141618 100%);
  box-shadow: var(--shadow-lg);
}
.tak3d-stage canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: pan-y; cursor: grab;
  opacity: 0; transition: opacity 0.7s ease;
}
.tak3d-stage.is-ready canvas { opacity: 1; }
.tak3d-stage.is-dragging canvas { cursor: grabbing; }
.tak3d-loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted-dark); font-size: 14px; letter-spacing: 0.04em;
}
.tak3d-stage.is-ready .tak3d-loading { display: none; }

.tak3d-label, .tak3d-hint {
  position: absolute; top: 16px; z-index: 2;
  padding: 7px 14px; border-radius: 999px;
  font-weight: 700; font-size: 13.5px; line-height: 1.2;
  pointer-events: none;
}
.tak3d-label { left: 16px; max-width: calc(100% - 32px); background: var(--terra); color: var(--white); letter-spacing: 0.02em; }
.tak3d-hint {
  top: auto; bottom: 18px; right: 16px;
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(20, 22, 24, 0.6); color: rgba(255, 255, 255, 0.86); font-weight: 600;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.4s;
}
.tak3d-stage.is-touched .tak3d-hint { opacity: 0; }
.tak3d-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(255, 255, 255, 0.12); z-index: 2; }
.tak3d-bar i { display: block; height: 100%; background: var(--terra); transform-origin: left center; transform: scaleX(0); }

/* ---------- Forsiden: velg en jobb ---------- */
.tak3d-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 30px; }
.tak3d-split > .tak3d-stage { aspect-ratio: 16 / 8.2; }
.tak3d-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tak3d-tab {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: 14px;
  background: var(--white); border: 1px solid var(--line); color: var(--text);
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tak3d-tab:hover { transform: translateY(-1px); border-color: var(--terra); }
.tak3d-tab strong { display: block; font-family: var(--font-display); font-size: 17.5px; letter-spacing: -0.01em; line-height: 1.2; }
.tak3d-tab small { display: block; color: var(--muted); font-size: 14.5px; line-height: 1.4; margin-top: 3px; }
.tak3d-tab .tak3d-go { margin-left: auto; color: var(--muted-dark); display: inline-flex; }
.tak3d-tab.is-active { border-color: var(--terra); box-shadow: 0 0 0 1px var(--terra), var(--shadow); }
.tak3d-tab.is-active .icon-bubble { background: var(--terra); color: var(--white); }
.tak3d-tab.is-active .tak3d-go { color: var(--terra); }
.tak3d-controls .card-link { margin-top: 18px; }

/* ---------- Nytt tak: taket bygges mens man ruller ---------- */
.tak3d-scrolly { border-bottom: 1px solid var(--line); }
.tak3d-scrolly .section-head { margin-bottom: 20px; }
.tak3d-scrolly-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr); gap: 64px; align-items: start; }
.tak3d-sticky { position: sticky; top: 104px; }
.tak3d-sticky .tak3d-stage { aspect-ratio: auto; height: min(calc(100vh - 150px), 620px); min-height: 320px; }
.tak3d-steps { counter-reset: lag; }
.tak3d-stepcard {
  counter-increment: lag;
  min-height: 64vh; display: flex; flex-direction: column; justify-content: center;
  opacity: 0.3; transition: opacity 0.35s;
}
.tak3d-stepcard.is-active { opacity: 1; }
.tak3d-stepcard::before {
  content: "0" counter(lag);
  font-family: var(--font-display); font-weight: 900; font-size: 52px; line-height: 1;
  color: var(--terra); letter-spacing: -0.04em; margin-bottom: 14px;
}
.tak3d-stepcard h3 { font-size: 28px; margin-bottom: 10px; }
.tak3d-stepcard p { color: var(--muted); font-size: 18px; max-width: 420px; }
.tak3d-stepcard p + p { margin-top: 10px; }
/* Det ferdige taket blir stående mens denne ruller forbi */
.tak3d-done { min-height: 44vh; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.tak3d-done h3 { font-size: 28px; margin-bottom: 10px; }
.tak3d-done p { color: var(--muted); font-size: 18px; max-width: 420px; }
.tak3d-done .btn { margin-top: 22px; }

/* Uten 3D: stegene vises som vanlige kort */
html:not(.js) .tak3d-scrolly-grid, .no-tak3d .tak3d-scrolly-grid { display: block; }
html:not(.js) .tak3d-sticky, .no-tak3d .tak3d-sticky { display: none; }
html:not(.js) .tak3d-done, .no-tak3d .tak3d-done { min-height: 0; margin-top: 28px; }
html:not(.js) .tak3d-steps, .no-tak3d .tak3d-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; margin-top: 24px; }
html:not(.js) .tak3d-stepcard, .no-tak3d .tak3d-stepcard {
  min-height: 0; opacity: 1; justify-content: flex-start;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px;
}

/* ---------- Takfornying og takvask: dra spaken ---------- */
.prose figure.tak3d-figure { background: var(--white); border: 1px solid var(--line); }
.tak3d-figure .tak3d-stage { border-radius: 0; box-shadow: none; aspect-ratio: 16 / 10; }
.tak3d-panel { padding: 20px 24px 24px; }
.tak3d-panel-top { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.tak3d-range-label { font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }
.tak3d-range {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 46px; margin: 6px 0 0; background: transparent; cursor: pointer;
}
.tak3d-range::-webkit-slider-runnable-track {
  height: 10px; border-radius: 999px;
  background: linear-gradient(90deg, var(--terra) var(--p, 0%), var(--line) var(--p, 0%));
}
.tak3d-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 36px; height: 36px; margin-top: -13px; border-radius: 50%;
  background: var(--terra); border: 4px solid var(--white);
  box-shadow: 0 2px 10px rgba(20, 22, 24, 0.32);
}
.tak3d-range::-moz-range-track { height: 10px; border-radius: 999px; background: var(--line); }
.tak3d-range::-moz-range-progress { height: 10px; border-radius: 999px; background: var(--terra); }
.tak3d-range::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--terra); border: 4px solid var(--white);
  box-shadow: 0 2px 10px rgba(20, 22, 24, 0.32);
}
.tak3d-range:focus-visible { outline: 3px solid var(--terra); outline-offset: 2px; border-radius: 999px; }
.tak3d-ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; font-weight: 600; }
.tak3d-swatches { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.tak3d-swatch {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px 7px 8px; border-radius: 999px;
  background: var(--white); border: 1px solid var(--line); color: var(--text);
  font-weight: 600; font-size: 14.5px; cursor: pointer;
}
.tak3d-swatch i { width: 20px; height: 20px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.tak3d-swatch:hover { border-color: var(--terra); }
.tak3d-swatch.is-active { border-color: var(--terra); box-shadow: 0 0 0 1px var(--terra); }
.tak3d-segs { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--sand); }
.tak3d-seg {
  padding: 8px 18px; border-radius: 999px; border: 0; background: transparent; color: var(--text);
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.tak3d-seg.is-active { background: var(--ink); color: var(--white); }
.prose .tak3d-figure figcaption { border-top: 1px solid var(--line); }

/* ---------- Skjermbredder ---------- */
@media (max-width: 960px) {
  .tak3d-split { gap: 24px; }
  .tak3d-split > .tak3d-stage { aspect-ratio: 4 / 3; }
  .tak3d-tabs { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .tak3d-tab { align-items: center; }
  .tak3d-scrolly-grid { display: block; }
  .tak3d-sticky { top: 72px; z-index: 5; margin: 0 -20px; padding: 10px 20px 12px; background: var(--white); }
  .tak3d-sticky .tak3d-stage { height: 38vh; min-height: 240px; border-radius: var(--radius); }
  .tak3d-stepcard { min-height: 46vh; justify-content: flex-start; padding-top: 22px; }
  .tak3d-stepcard::before { font-size: 40px; margin-bottom: 8px; }
  .tak3d-stepcard h3 { font-size: 23px; }
  .tak3d-stepcard p { font-size: 16.5px; max-width: none; }
  .tak3d-done { min-height: 30vh; justify-content: flex-start; padding-top: 22px; }
  .tak3d-done h3 { font-size: 23px; }
  .tak3d-done p { font-size: 16.5px; }
}
@media (max-width: 640px) {
  .tak3d-stage, .tak3d-split > .tak3d-stage { aspect-ratio: 1 / 1; border-radius: var(--radius); }
  .tak3d-figure .tak3d-stage { aspect-ratio: 4 / 3.4; }
  .tak3d-panel { padding: 16px 16px 20px; }
  .tak3d-range-label { font-size: 17.5px; }
  .tak3d-label { font-size: 12.5px; top: 12px; left: 12px; }
  .tak3d-hint { font-size: 12.5px; right: 12px; bottom: 14px; }
}
