/* =========================================================
   NATURFAG – AKT 1: «Partikler, atomer og kjemiske reaksjoner»
   Grunnoppsett for arbeidshefte-markupen + det som er spesielt
   for denne akten (simulering, periodesystem, atommodeller).
   Lastes ETTER backstage.css og FØR kapittel.css, som kler
   part / goals / key / tip / task / fasit i Backstage.
   Rå hex finnes bare i det lokale fargekartet øverst.
   ========================================================= */

:root {
  /* Atommodeller: fargene skiller bare delene fra hverandre */
  --proton:   #B8246A;
  --neutron:  #6E5A64;
  --electron: var(--gold);
  --oxy:      #A8324A;
  --hyd:      #4A3640;
  --carb:     #2A2025;
  --iron:     #8A5A3C;
  --nitro:    #3F6B7A;
  --on-atom:  #FFFFFF;

  /* Periodesystem: lyse ruter med mørk tekst */
  --el-ink:       var(--paper-ink);
  --el-metal:     #DDB0C8;
  --el-nonmetal:  #A9CDBB;
  --el-metalloid: #DDCFA1;
  --el-noble:     #B2BFD1;
}

/* Sidegrunnlag */
main.wrap { margin: 0 auto; padding-bottom: var(--s-8); display: flex; flex-direction: column; }
section.part { display: flex; flex-direction: column; }
.part-head { display: flex; }
.num { flex: none; display: grid; place-items: center; }
nav.toc { display: flex; flex-wrap: wrap; }
nav.toc a { text-decoration: none; border-radius: var(--r-pill); }

.goals, .key, .tip { display: flex; flex-direction: column; gap: var(--s-2); }
.goals ul { margin: 0; }
ol.clean, ul.clean { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: var(--s-2); }
.ex { display: flex; flex-direction: column; gap: var(--s-3); }

/* Fasit */
details.fasit { border: 1px dashed var(--line-strong); padding: var(--s-2) var(--s-3); }
section.part details.fasit summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
details.fasit[open] summary { margin-bottom: var(--s-2); }

/* Kort */
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-3); }
.card { border: 1px solid var(--line); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); }
.card h3 { font-size: 1.1875rem; }
.pill {
  align-self: flex-start;
  font-family: var(--f-ui); font-weight: 700; font-size: var(--fs-xs);
  padding: 2px 10px; border-radius: var(--r-pill);
  background: var(--pink-soft); color: var(--pink-2);
}

/* Figurer */
.figure { border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s-3); overflow-x: auto; }
.figure--tight { padding: var(--s-1); }
.figure svg { width: 100%; height: auto; min-width: 300px; }
.cap { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--s-2); }

svg text { font-family: var(--f-body); fill: var(--ink); }
svg .t-muted { fill: var(--muted); }
svg .box { fill: none; stroke: var(--line-field); stroke-width: 2; }
svg .p { fill: var(--proton); }
svg .n { fill: var(--neutron); }
svg .e { fill: var(--electron); }
svg .orbit { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 5; }
svg .O, svg .H, svg .C, svg .Fe, svg .N { stroke: var(--ink); stroke-width: 1.5; }
svg .O { fill: var(--oxy); }
svg .H { fill: var(--hyd); }
svg .C { fill: var(--carb); }
svg .Fe { fill: var(--iron); }
svg .N { fill: var(--nitro); }
svg .part { fill: var(--pink); stroke: var(--on-pink); stroke-width: 1; }
svg .arrow { stroke: var(--ink); stroke-width: 3; fill: none; }
svg .ah { fill: var(--ink); }
svg .lbl-w { fill: var(--on-atom); font-weight: 700; }

/* Simulering */
.sim { display: flex; flex-direction: column; gap: var(--s-3); }
.sim canvas { width: 100%; height: 260px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); }
.sim-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.sim-row label { font-family: var(--f-ui); font-weight: 700; }
input[type="range"] { flex: 1; min-width: 180px; height: 44px; accent-color: var(--pink); }
.state { font-family: var(--f-ui); font-weight: 700; font-size: var(--fs-lg); color: var(--pink); }

/* Periodesystem: fyller alltid bredden, rutene er 52px høye */
.ptable { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: clamp(3px, 1vw, 5px); }
.el {
  appearance: none; border: 2px solid transparent; border-radius: var(--r-xs);
  padding: var(--s-1) 2px; min-height: 52px; cursor: pointer;
  font-family: var(--f-ui); color: var(--el-ink); line-height: 1.1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform var(--t-press) var(--ease-out);
}
.el:active { transform: scale(0.97); }
.el .z { font-size: 11px; font-variant-numeric: tabular-nums; }
.el .s { font-weight: 700; font-size: 1.25rem; }
.el.metal, .legend i.metal { background: var(--el-metal); }
.el.nonmetal, .legend i.nonmetal { background: var(--el-nonmetal); }
.el.metalloid, .legend i.metalloid { background: var(--el-metalloid); }
.el.noble, .legend i.noble { background: var(--el-noble); }
.el[aria-pressed="true"] { border-color: var(--el-ink); box-shadow: 0 0 0 2px var(--pink); }
.gap { visibility: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-3); font-size: var(--fs-sm); }
.legend span { display: flex; align-items: center; gap: var(--s-2); }
.legend i { width: 16px; height: 16px; border-radius: var(--r-xs); display: inline-block; }

.info {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: var(--s-4);
}
@media (max-width: 560px) { .info { grid-template-columns: 1fr; } }
.info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: var(--s-1) var(--s-3); font-size: var(--fs-sm); }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.bigsym { display: flex; align-items: baseline; gap: var(--s-3); }
.bigsym .s { font-family: var(--f-display); font-size: 3.25rem; line-height: 1; }
.bigsym .nm { font-family: var(--f-ui); font-size: var(--fs-lg); font-weight: 700; }

/* Sammenligning og tabeller */
.compare { display: flex; flex-direction: column; gap: var(--s-3); }
.compare .sel { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; }
select {
  font: inherit; font-size: 1rem; min-height: 44px; padding: var(--s-1) var(--s-3);
  border: 1px solid var(--line-field); background: var(--field); color: var(--ink);
}
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 1rem; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); padding: var(--s-2); text-align: left; }
th { color: var(--muted); font-weight: 400; }

/* Audition (quiz og sjekkliste) */
#del6 .part-head h2::before { content: "Audition"; color: var(--pink); }
.q { border: 1px solid var(--line); border-radius: var(--r-sm); display: flex; flex-direction: column; gap: var(--s-2); }
.q p { font-weight: 700; }
.opts { display: flex; flex-direction: column; gap: var(--s-2); }
.opts button {
  font: inherit; font-size: 1rem; text-align: left; cursor: pointer;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-field); background: none; color: var(--ink);
}
.opts button.right { background: var(--good-soft); border-color: var(--good); }
.opts button.wrong { background: var(--bad-soft); border-color: var(--bad); }
.fb { font-size: 1rem; }
.fb.ok { color: var(--good); }
.fb.no { color: var(--bad); }
.score { font-weight: 700; font-size: var(--fs-lg); }
.check { display: flex; flex-direction: column; gap: var(--s-2); }
.check label {
  display: flex; gap: var(--s-3); align-items: flex-start; min-height: 44px; cursor: pointer;
  padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.check input { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--good); }
