/* =========================================================
   SKOLEKALKULATOR – TOOL STANDARD V1

   Felles standard for vanlige læringsverktøy.

   Kalkulatorspesifikke CSS-filer skal kun inneholde det som
   er nødvendig for akkurat det aktuelle matematikkverktøyet.
   ========================================================= */


/* SIDE */

.tool-page {
  min-height: 60vh;
}

.tool-width {
  max-width: 820px;
}


/* INTRO */

.tool-intro {
  padding: 38px 0 26px;
}

.tool-intro h1 {
  margin-bottom: 10px;

  font-size: clamp(30px, 4vw, 42px);
}

.tool-intro p:not(.eyebrow) {
  max-width: 680px;

  margin-bottom: 0;

  color: var(--muted);

  font-size: 16px;
  line-height: 1.6;
}


/* OPPGAVETYPE / REGNEART */

.operation-section {
  padding: 4px 0 18px;
}


/* KALKULATOR */

.calculator-section {
  padding: 18px 0 42px;
}

.calculator-card {
  padding: 26px;

  border: 1px solid var(--line);
  border-radius: 14px;

  background: var(--surface);
}


/* HOVEDKNAPP */

.calculate-button {
  width: 100%;
  min-height: 50px;

  margin-top: 24px;

  border: 0;
  border-radius: 9px;

  background: #225cc4;
  color: #fff;

  font-weight: 800;

  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .calculate-button:hover {
    background: #194b9f;
  }
}


/* FEILMELDING */

.error-message {
  margin: 16px 0 0;

  color: #c34242;

  font-size: 14px;
  line-height: 1.5;
}


/* LØSNING */

.solution-section {
  padding: 8px 0 54px;
}

.solution-heading {
  margin-bottom: 20px;
}

.solution-heading h2 {
  margin-bottom: 0;

  font-size: 27px;
}

.solution-content {
  display: grid;

  gap: 12px;
}


/* STEG */

.solution-block {
  padding: 18px 20px;

  border: 1px solid var(--line);
  border-radius: 11px;

  background: var(--surface);
}

.solution-block h3 {
  margin: 0 0 7px;

  font-size: 16px;
}

.solution-block p {
  margin: 0;

  color: var(--muted);

  font-size: 15px;
  line-height: 1.65;
}

.solution-block p + p {
  margin-top: 7px;
}


/* MATEMATIKK */

.math-line {
  margin-top: 10px !important;

  color: var(--text) !important;

  font-size: 18px !important;
  font-weight: 700;
}

.final-answer {
  border-color: var(--accent);
}

.final-answer .math-line {
  font-size: 24px !important;
}

.explanation {
  background: var(--surface-soft);
}


/* =========================================================
   MELLOMREGNINGSPANEL

   Brukes når et eget mellomregningspanel gir pedagogisk verdi.
   Desktop: ved siden av løsningen.
   Mobil: under løsningen.
   ========================================================= */

.solution-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;

  gap: 16px;

  align-items: start;
}

.side-calculator {
  position: sticky;
  top: 20px;

  padding: 18px;

  border: 1px solid var(--line);
  border-radius: 11px;

  background: var(--surface-soft);
}

.side-calculator-label {
  margin: 0 0 6px;

  color: var(--muted);

  font-size: 11px;
  font-weight: 800;

  letter-spacing: .08em;
}

.side-calculator h3 {
  margin: 0 0 14px;

  font-size: 15px;
}

.side-calculator-expression,
.side-calculator-result {
  padding: 12px 14px;

  border: 1px solid var(--line);
  border-radius: 8px;

  background: var(--surface);

  text-align: center;

  font-variant-numeric: tabular-nums;
}

.side-calculator-expression {
  color: var(--text);

  font-size: 20px;
  font-weight: 800;
}

.side-calculator-result {
  margin-top: 8px;

  color: var(--accent);

  font-size: 22px;
  font-weight: 900;
}

.side-calculator-note {
  margin: 10px 0 0;

  color: var(--muted);

  font-size: 12px;
  line-height: 1.5;
}


/* UTVIDET MELLOMREGNING */

.side-help {
  display: grid;

  gap: 16px;
}

.side-help-step {
  display: grid;

  gap: 10px;
}

.side-help-step + .side-help-step {
  padding-top: 14px;

  border-top: 1px solid var(--line);
}

.side-help-step > strong {
  font-size: 14px;
}

.side-help-step p {
  margin: 0;

  color: var(--muted);

  font-size: 13px;
  line-height: 1.55;
}

.side-help-math {
  display: flex;
  flex-wrap: wrap;

  gap: 7px;

  align-items: center;
  justify-content: center;

  padding: 12px;

  border: 1px solid var(--line);
  border-radius: 8px;

  background: var(--bg);
  color: var(--text);

  font-size: 17px;
  font-weight: 800;

  font-variant-numeric: tabular-nums;
}

.side-help-math-column {
  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  gap: 8px;

  margin: 12px auto 0;

  text-align: center;
}

.side-help-math-column span {
  display: block;

  width: 100%;
}

.side-help-line {
  margin-top: 4px;
  padding-top: 5px;

  border-top: 1px solid var(--text);
}

.side-help-answer {
  padding: 11px 12px;

  border: 1px solid var(--accent);
  border-radius: 8px;

  background: var(--surface);
  color: var(--text);

  text-align: center;

  font-size: 16px;
  font-weight: 800;
}

.side-calculator-result strong {
  display: block;

  margin-bottom: 4px;

  color: var(--muted);

  font-size: 11px;
}

.side-calculator-result div {
  color: var(--accent);

  font-size: 24px;
  font-weight: 900;
}


/* DARK MODE */

@media (prefers-color-scheme: dark) {
  .error-message {
    color: #ff8b8b;
  }
}


/* MOBIL */

@media (max-width: 700px) {

  .tool-intro {
    padding: 28px 0 22px;
  }

  .tool-intro h1 {
    font-size: 30px;
  }

  .calculator-card {
    padding: 20px 16px;
  }

  .solution-layout {
    grid-template-columns: 1fr;
  }

  .side-calculator {
    position: static;
  }

}

/* =========================================================
   FELLES MÅLEENHETSFELT
   Brukes i verktøy der oppgaven inneholder fysiske mål.
   ========================================================= */

.measurement-unit-field {
  width: min(100%, 300px);
  margin: 0 auto 24px;
}

.measurement-unit-field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.measurement-unit-field select {
  width: 100%;
  height: 50px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.measurement-unit-field p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* =========================================================
   FELLES LØSNINGSLAYOUT MED VISUELL STØTTE
   Brukes på tvers av trinn.
   ========================================================= */

.support-solution-width {
  width: min(100% - 32px, 1080px);
  margin: 0 auto;
}

.support-solution-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 28px;
  align-items: start;
}

.support-solution-steps {
  min-width: 0;
}

.support-visual-panel {
  position: sticky;
  top: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.support-visual-eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.support-visual-panel h3 {
  margin: 0 0 18px;
}

.support-visual-help {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.support-visual-help p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.5;
}

.support-visual-help p:last-child {
  margin-bottom: 0;
}

.support-visual-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .support-solution-layout {
    grid-template-columns: 1fr;
  }

  .support-visual-panel {
    position: static;
  }
}

/* NULLSTILL */
.reset-button {
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .reset-button:hover {
    background: var(--surface-soft, #f4f6f8);
  }
}

.reset-button:focus-visible {
  outline: 3px solid #225cc4;
  outline-offset: 2px;
}
