/*
 * LUMEN – stylesheet
 * ---------------------------------------------------------------
 * ASA's identitet:
 *   Navy      #0E3A5D  – primær
 *   Navy dyb  #082843  – tekst
 *   Blå       #2F80C9  – accent
 *   Lyseblå   #82B3DF
 *   Lys tone  #D5E6F4
 *   Knækket   #F2F4F7  – sidebaggrund
 *
 * Typografi:
 *   Fraunces – overskrifter og tal (serif, optical size)
 *   Geist    – brødtekst (sans)
 */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --navy:        #0E3A5D;
  --navy-deep:   #082843;
  --blue:        #2F80C9;
  --blue-light:  #82B3DF;
  --tint:        #D5E6F4;
  --tint-soft:   #E8F0F8;
  --off-white:   #F2F4F7;
  --paper:       #FFFFFF;
  --line:        #DDE3EA;
  --line-strong: #BFC9D4;
  --text:        #082843;
  --text-muted:  #4A5C70;
  --text-faint:  #7A8896;

  --ok:    #2F8F4E;
  --warn:  #C08A1F;
  --err:   #B8402B;

  --radius:  4px;
  --radius-lg: 8px;

  --serif: 'Fraunces', 'Times New Roman', Georgia, serif;
  --sans:  'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;

  --shadow-soft: 0 1px 0 rgba(8, 40, 67, .04);

  --max: 1180px;
}

/* ── Base reset ────────────────────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--off-white);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s; }
a:hover { border-bottom-color: currentColor; }
img { max-width: 100%; }

/* Fokus – ASA-blå, ikke browserdefault */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 12px 24px;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  color: var(--navy-deep);
  border: 0;
  line-height: 1;
}
.wordmark-l {
  color: var(--blue);
}
.subtitle {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 400;
}
.attribution {
  margin: 0;
  color: var(--text-faint);
  font-size: 13px;
  text-align: right;
}
.attribution a {
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .topbar-inner {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 18px 20px;
  }
  .attribution { text-align: left; }
}

/* ── Hovedområde – værktøjet ────────────────────────────── */
.tool {
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px 24px 64px;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 32px;
  align-items: start;
}
@media (max-width: 960px) {
  .tool {
    grid-template-columns: 1fr;
    padding: 28px 20px 48px;
    gap: 24px;
  }
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-soft);
}
@media (max-width: 640px) {
  .panel { padding: 22px; }
}

.panel-title {
  margin: 0 0 24px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--navy-deep);
}
.panel-output .panel-title {
  color: var(--text-muted);
  font-style: italic;
  font-size: 18px;
  margin-bottom: 8px;
}

/* ── Formularfelter ─────────────────────────────────────── */
.field {
  margin-bottom: 24px;
  border: 0;
  padding: 0;
  min-width: 0;
}
.field:last-child { margin-bottom: 0; }

.field > label,
.field > legend {
  display: block;
  font-weight: 500;
  color: var(--navy-deep);
  margin-bottom: 8px;
  font-size: 15px;
}

.field-note {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Select + input – rektangulær, seriøs */
select, input[type="number"], input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: border-color .15s, box-shadow .15s;
  min-height: 42px;
}
select {
  appearance: none;
  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'><path fill='none' stroke='%23082843' stroke-width='1.6' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
select:hover, input:hover { border-color: var(--navy); }
select:focus, input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 128, 201, .18);
  outline: none;
}

/* Enhed vist ved siden af tal (m, W, lm) */
.unit-input {
  position: relative;
  display: flex;
  align-items: center;
}
.unit-input input {
  padding-right: 42px;
}
.unit-input .unit {
  position: absolute;
  right: 12px;
  color: var(--text-faint);
  font-size: 14px;
  pointer-events: none;
}

.dim-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.dim-grid.two { grid-template-columns: repeat(2, 1fr); }
.dim-grid > label {
  display: block;
}
.dim-grid > label > span {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
@media (max-width: 480px) {
  .dim-grid, .dim-grid.two { grid-template-columns: 1fr 1fr; }
}

/* Segmented control – bruges til reflektans og omgivelser */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.segmented label {
  position: relative;
  display: block;
  cursor: pointer;
}
.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented span {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  text-align: left;
  transition: all .15s;
  background: var(--paper);
  font-weight: 500;
  color: var(--navy-deep);
  font-size: 14px;
  line-height: 1.3;
}
.segmented span small {
  display: block;
  font-weight: 400;
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 3px;
}
.segmented label:hover span {
  border-color: var(--navy);
}
.segmented input:checked + span {
  border-color: var(--blue);
  background: var(--tint-soft);
  color: var(--navy-deep);
  box-shadow: 0 0 0 1px var(--blue) inset;
}
.segmented input:focus-visible + span {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
@media (max-width: 560px) {
  .segmented { grid-template-columns: 1fr; gap: 6px; }
  .segmented span small { display: inline; margin-left: 8px; }
}

/* Avancerede felter i disclosure */
.advanced {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 12px;
}
.advanced summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 13px;
  list-style: none;
  padding: 4px 0;
  user-select: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before {
  content: "+ ";
  font-weight: 600;
}
.advanced[open] summary::before { content: "− "; }
.advanced .stacked > span {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  margin-top: 10px;
}

/* ── Resultatpanel ─────────────────────────────────────── */
.status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--tint-soft);
  border: 1px solid var(--tint);
  margin-bottom: 24px;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-faint);
  margin-top: 6px;
  flex-shrink: 0;
}
.status-text strong {
  display: block;
  color: var(--navy-deep);
  font-weight: 500;
  font-size: 15px;
}
.status-text span {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.status[data-state="ok"]    { background: #EAF6EE; border-color: #BFDCC7; }
.status[data-state="ok"] .status-dot { background: var(--ok); }

.status[data-state="over"]  { background: #FCF3E0; border-color: #E7CE97; }
.status[data-state="over"] .status-dot { background: var(--warn); }

.status[data-state="under"] { background: #FBECE7; border-color: #E5B9AB; }
.status[data-state="under"] .status-dot { background: var(--err); }

/* Overskriftstal – Fraunces */
.headline-number {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.hn-label {
  font-family: var(--serif);
  font-style: italic;
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 400;
}
.hn-value {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(48px, 8vw, 76px);
  color: var(--navy-deep);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* Metrics grid */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px 32px;
  margin: 0 0 28px;
  padding: 0;
}
.metrics > div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.metrics dt {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.metrics dd {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--navy-deep);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.metrics dd small {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 400;
  margin-left: 6px;
  letter-spacing: 0;
}
@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr; gap: 14px; }
}

/* Visualisering */
.visualization {
  margin: 8px 0 24px;
  padding: 0;
}
.visualization svg {
  display: block;
  width: 100%;
  height: auto;
  background: var(--tint-soft);
  border: 1px solid var(--tint);
  border-radius: var(--radius);
}
.visualization figcaption {
  margin-top: 8px;
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
  text-align: center;
}

/* Forklaring */
.explainer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 8px;
}
.explainer summary {
  cursor: pointer;
  color: var(--blue);
  font-size: 14px;
  list-style: none;
  user-select: none;
}
.explainer summary::-webkit-details-marker { display: none; }
.explainer summary::before {
  content: "+ ";
  font-weight: 600;
}
.explainer[open] summary::before { content: "− "; }
.explainer-body {
  padding-top: 12px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}
.explainer-body p { margin: 8px 0; }
.explainer-body ul { padding-left: 20px; margin: 8px 0; }
.explainer-body em {
  font-family: var(--serif);
  font-style: italic;
  color: var(--navy-deep);
  padding: 0 1px;
}
.formula {
  background: var(--tint-soft);
  border-left: 3px solid var(--blue);
  padding: 8px 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 16px;
}

/* ── Footer ───────────────────────────────────────────── */
.foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 24px 48px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}
.foot p { margin: 0; }

/* Print – gør værktøjet dokumentagtigt hvis nogen printer */
@media print {
  body { background: white; }
  .topbar, .foot { border: 0; }
  .panel { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  .tool { grid-template-columns: 1fr; }
  .advanced, .explainer { display: none; }
}
