/* =========================================================
   BRØK
   Kun styles som er spesifikke for Brøk.
   Felles verktøystil styres av school-tool-standard.css
   ========================================================= */


/* BRØKINPUT */

.fraction-input-area {
  display: flex;

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

  gap: 30px;
}

.fraction-input {
  text-align: center;
}

.fraction-input > label {
  display: block;

  margin-bottom: 12px;

  color: var(--muted);

  font-size: 13px;
  font-weight: 700;
}

.fraction-fields {
  width: 92px;

  display: grid;

  gap: 7px;
}

.fraction-fields input {
  width: 100%;
  height: 48px;

  padding: 4px 8px;

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

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

  text-align: center;

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

.fraction-line {
  display: block;

  height: 2px;

  background: var(--text);
}

.operator {
  padding-bottom: 44px;

  font-size: 30px;
  font-weight: 700;
}


/* VISUELLE BRØKER I LØSNINGEN */

.fraction-display {
  display: inline-grid;
  grid-template-rows: auto auto;

  min-width: 1.7em;

  margin: 0 .14em;

  vertical-align: middle;

  text-align: center;

  line-height: 1.05;
}

.fraction-top {
  display: block;

  padding: 0 .16em .08em;

  border-bottom: 2px solid currentColor;
}

.fraction-bottom {
  display: block;

  padding: .08em .16em 0;
}

.math-line .fraction-display {
  font-size: 1.08em;
}

.final-answer .fraction-display {
  font-size: 1.28em;
}

.solution-block p {
  overflow-wrap: anywhere;
}


/* REGNEARTER */

.operation-picker {
  width: min(100%, 560px);

  margin: 0 auto 30px;

  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 9px;
}

.operation-button {
  min-width: 0;
  min-height: 68px;

  padding: 11px 12px;

  display: flex;
  flex-direction: column;

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

  gap: 3px;

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

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

  text-align: left;

  cursor: pointer;
}

.operation-title {
  display: block;

  color: var(--text);

  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.operation-description {
  display: block;

  color: var(--muted);

  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
}

.operation-button.active {
  border-color: var(--accent);

  background: var(--surface);

  box-shadow: none;
}

.operation-button.active .operation-title {
  color: var(--accent);
}

.fraction-input.is-hidden,
.operator.is-hidden {
  display: none;
}


/* UTVIDE BRØK */

.expand-factor-wrap {
  max-width: 320px;

  margin: 24px auto 0;
}

.expand-factor-wrap label {
  display: block;

  margin-bottom: 8px;

  color: var(--muted);

  font-size: 13px;
  font-weight: 700;
}

.expand-factor-wrap input {
  width: 100%;
  height: 48px;

  padding: 0 12px;

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

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

  text-align: center;

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


/* DESIMAL / PROSENT TIL BRØK */

.tofraction-wrap {
  max-width: 380px;

  margin: 0 auto 4px;
}

.tofraction-type {
  display: grid;
  grid-template-columns: 1fr 1fr;

  gap: 6px;

  margin-bottom: 18px;
}

.tofraction-type-button {
  min-height: 42px;

  padding: 8px 12px;

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

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

  font-size: 13px;
  font-weight: 600;

  cursor: pointer;
}

.tofraction-type-button.active {
  border-color: var(--accent);

  color: var(--accent);
}

.tofraction-wrap label {
  display: block;

  margin-bottom: 8px;

  color: var(--muted);

  font-size: 13px;
  font-weight: 700;
}

.tofraction-wrap input {
  width: 100%;
  height: 48px;

  padding: 0 14px;

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

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

  text-align: center;

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


/* BRØK PÅ TALLINJA */

.fraction-numberline {
  position: relative;

  width: 100%;
  max-width: 720px;

  margin: 36px auto 20px;
  padding-top: 2px;

  display: grid;
  grid-template-columns:
    repeat(var(--numberline-points), minmax(0, 1fr));

  align-items: start;
}

.numberline-track {
  position: absolute;

  top: 10px;
  left: 0;
  right: 0;

  height: 3px;

  border-radius: 999px;

  background: #24364b;
}

.numberline-point {
  position: relative;

  z-index: 1;

  min-width: 0;

  display: flex;
  flex-direction: column;

  align-items: center;
}

.numberline-marker {
  width: 3px;
  height: 20px;

  border-radius: 2px;

  background: #24364b;
}

.numberline-label {
  min-height: 42px;

  margin-top: 8px;

  display: flex;

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

  font-weight: 600;
}

.numberline-point.selected .numberline-marker {
  width: 14px;
  height: 14px;

  margin-top: 3px;
  margin-bottom: 3px;

  border-radius: 50%;

  background: var(--accent);

  box-shadow: 0 0 0 5px rgba(34, 92, 196, .14);
}

.numberline-point.selected .numberline-label {
  color: var(--accent);

  font-weight: 800;
}

.numberline-label .fraction-display {
  font-size: .82em;
}


/* HOVER */

@media (hover: hover) and (pointer: fine) {

  .operation-button:hover {
    border-color: var(--accent);
  }

}


/* DARK MODE */

@media (prefers-color-scheme: dark) {

  .fraction-fields input,
  .expand-factor-wrap input,
  .tofraction-wrap input {
    color-scheme: dark;
  }

}


/* MOBIL */

@media (max-width: 700px) {

  .fraction-input-area {
    gap: 18px;
  }

  .fraction-fields {
    width: 78px;
  }

  .operator {
    padding-bottom: 42px;
  }

}

@media (max-width: 620px) {

  .operation-picker {
    width: 100%;

    grid-template-columns: 1fr;

    gap: 10px;
  }

  .operation-button {
    min-height: auto;

    padding: 12px 14px;
  }

}

@media (max-width: 600px) {

  .fraction-numberline {
    overflow-x: auto;

    justify-content: stretch;
  }

  .numberline-label {
    font-size: .8rem;
  }

}

.fraction-visual-item {
  margin-bottom: 16px;
}

.fraction-visual-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.fraction-visual-label span {
  color: var(--muted);
}

.fraction-visual-track {
  height: 30px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.fraction-visual-fill {
  height: 100%;
  background: var(--accent);
  opacity: .72;
}

.fraction-value-card {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  text-align: center;
}

.fraction-value-card strong,
.fraction-value-card span {
  display: block;
}

.fraction-value-card strong {
  font-size: 22px;
}

.fraction-value-card span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
}

.fraction-numberline {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 28px 0 18px;
}

.fraction-numberline-line {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: var(--text);
}

.fraction-numberline-marker {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
}

.fraction-numberline-start,
.fraction-numberline-end {
  font-weight: 800;
}
