/* The chalkboard that every avtavle page shares, from the canvas prototype: its tokens, the phone
   column and how it scales (guest-page.md, "Layout"), the type scale, the fields, the logo, the
   parts of an SVG that every widget draws with, the word buttons, and Fjern alle from
   clearall.js. A widget's own rules go in a stylesheet beside its module. */

@font-face {
  font-family: "Nunito";
  src: url("fonts/Nunito-latin.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Nunito";
  src: url("fonts/Nunito-latin-ext.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* What the page is scaled by. Registered, so that it is a number where it is used. */
@property --zoom {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

:root {
  /* A container, so that 100cqw is the page's width without a scrollbar. */
  container-type: inline-size;

  /* A scrollbar that comes with a taller page does not narrow the page and move what is on it. */
  scrollbar-gutter: stable both-edges;

  /* Light is a whiteboard with blue marker, dark the green chalkboard (theme.md). */
  color-scheme: light dark;
  --board: light-dark(#F2F4F7, #232C29);
  --text: light-dark(#18315E, #EDEEE8);
  --muted: light-dark(#586785, #A8B1AC);
  --soft: light-dark(#2D4675, #D7DBD6);
  --closed: light-dark(#C3CBD9, #56605B);
  --line: light-dark(#8794AD, #7A847F);
  --hover: light-dark(#586785, #A8B1AC);
  --fill: light-dark(#1F3F78, #E6E4D8);
  --edge: light-dark(#0E2552, #F6F5EF);
  --ink: light-dark(#F2F4F7, #1D2520);
  --chosen: light-dark(#C7372F, #EC7A70);
  --chosen-hover: light-dark(#A82D26, #F39A92);
  --rule: light-dark(#D3D9E4, #4D5652);
  /* The board with its texture's mean over it, for where nothing draws the texture. */
  --bounce: light-dark(#F1F3F6, #27302D);

  --size-count: 12px;
  --size-label: 13px;
  --size-fine: 14px;
  --size-small: 15px;
  --size-body: 16px;
  --size-fact: 17px;
  --size-head: 18px;
  --size-mark: 20px;
  --size-logo: 24px;
  --size-title: 40px;
}

/* The switch's choice, which light-dark() follows (theme.js). */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

/* The board's ground, under what lies over the page too, which hides the page under it. Here for
   all of them, as make stamp stamps the texture's links in this stylesheet alone, and on the who
   card outside its zoom, which would coarsen the dust. The root has the colour alone, which shows
   where the page bounces past its ends. */
:root {
  background: var(--bounce);
}

body,
.whocard,
.lagret p,
.hits,
.clearbox .sure {
  background: image-set(url("dust.png?v=45a827cb") 1x, url("dust.svg?v=d9de1d0b") 2x) 0 0 / 256px 256px,
    url("smudge.png?v=72673136") 0 0 / 3200px 2000px, var(--board);
}

/* The same in black and fainter, as a wiped whiteboard is grey, by the system's theme or the
   switch's. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) :is(body, .whocard, .lagret p, .hits, .clearbox .sure) {
    background:
      image-set(url("dust-light.png?v=87bf32de") 1x, url("dust-light.svg?v=e73dec09") 2x) 0 0 / 256px 256px,
      url("smudge-light.png?v=50e2b0f4") 0 0 / 3200px 2000px, var(--board);
  }
}

:root[data-theme="light"] :is(body, .whocard, .lagret p, .hits, .clearbox .sure) {
  background:
    image-set(url("dust-light.png?v=87bf32de") 1x, url("dust-light.svg?v=e73dec09") 2x) 0 0 / 256px 256px,
    url("smudge-light.png?v=50e2b0f4") 0 0 / 3200px 2000px, var(--board);
}

/* A mouse or a trackpad stops at the page's ends. Not sideways, where a swipe goes back, and not
   on touch, which pulls to reload. */
@media (pointer: fine) {
  :root {
    overscroll-behavior-y: none;
  }
}

body {
  --beside: 18px;
  /* The column's 358px fill the page less 16px at each side, from 320px to 540px wide.
     tan(atan2(a, b)) is a / b as a number, which calc() cannot give from two lengths. */
  --zoom: tan(atan2(clamp(288px, 100cqw - 32px, 508px), 358px));
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Nunito, system-ui, sans-serif;
  font-size: var(--size-body);
  line-height: 1.45;
}

h1, h2, h3, p, ul {
  margin: 0;
}

a {
  color: var(--chosen);
}

a:hover {
  color: var(--chosen-hover);
}

:focus-visible {
  outline: 2px solid var(--edge);
  outline-offset: 3px;
}

/* A field's type, at --field. Where the page scales, it takes 16px of the screen at least, or iOS
   zooms in on the field as it takes the cursor. */
input,
textarea {
  font: inherit;
  font-size: var(--field, 1em);
}

@supports (zoom: tan(atan2(1cqw, 1px))) {
  input,
  textarea {
    font-size: max(var(--field, 1em), 16px / var(--zoom));
  }
}

/* The phone column, scaled by --zoom where the browser can work it out. Its gutters and height
   are divided by it, as zoom scales them too. */
.screen {
  box-sizing: border-box;
  max-width: 390px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 16px 32px;
  overflow: clip;
}

@supports (zoom: tan(atan2(1cqw, 1px))) {
  .screen {
    max-width: calc(358px + 32px / var(--zoom));
    min-height: calc(100vh / var(--zoom));
    padding: 20px calc(16px / var(--zoom)) 32px;
    zoom: var(--zoom);
  }
}

.screen, main {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Who marked something under its part (side.js), in a wrapper that takes no room. */
.whoin {
  display: contents;
}

/* Who marked something, on a wide screen: a card laid over the page beside the part (side.js),
   which places it once it is drawn, and until then lies where it adds no scrollbar. */
.whocard {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 4;
  visibility: hidden;
  pointer-events: none;
}

.whocard.pinned {
  pointer-events: auto;
}

.whocard > div {
  zoom: var(--zoom);
  position: relative;
  box-sizing: border-box;
  width: 358px;
  padding: 4px;
}

.whocard > div > .box .line {
  stroke: var(--hover);
}

/* Inside the card's chalk box and 4px clear of its line, so that the box stays put as a long list
   scrolls, and the scrollbar does not cover its right edge. */
.whocard > div > div {
  position: relative;
  box-sizing: border-box;
  max-height: calc((100vh - 16px) / var(--zoom) - 8px);
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 10px 12px;
}

@media (min-width: 900px) {
  body {
    /* 1.1 at 900px wide and 1.25 at 1280px, up to 1.5 from 1920px. */
    --zoom: tan(atan2(clamp(2816px, 100cqw + 1920px, 3840px), 2560px));
  }

  .screen:not(.alone) {
    padding-block: 28px 48px;
  }

  main:not(:has(.bygg), .alone > *) {
    gap: 26px;
  }
}

h1, .hf {
  font-weight: 800;
  line-height: 1.15;
}

.title {
  font-size: var(--size-title);
}

.cap {
  color: var(--soft);
  font-size: var(--size-small);
  font-weight: 800;
}

.note {
  color: var(--soft);
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.fine {
  color: var(--muted);
  font-size: var(--size-fine);
  font-weight: 700;
}

/* The pages of text: /om, /personvern and /vilkar. */
.text,
.text section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text {
  gap: 22px;
}

.text h2 {
  font-size: var(--size-head);
  font-weight: 800;
  line-height: 1.25;
}

.text ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 1.2em;
}

/* The links to the pages of text, at the bottom of the screen on a short page, under a line
   that ends the page. */
.pagelinks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 26px;
  margin-top: auto;
  padding-top: 28px;
  font-size: var(--size-fine);
  font-weight: 700;
}

.pagelinks > a {
  padding-block: 6px;
  color: var(--muted);
  text-decoration: none;
}

.pagelinks > a:hover {
  color: var(--text);
}

.pagelinks > .gratis {
  flex-basis: 100%;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: var(--size-fine);
  font-weight: 700;
  text-align: center;
}

.pagelinks .footrule {
  position: relative;
  flex-basis: 100%;
  height: 4px;
  margin-bottom: 4px;
}

.footrule > svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* alve.no's frog, animated by site/frog.js, holds on to the right end of the line. Its pixels
   stay 2px in the zoomed column, so its sizes are divided by the zoom. Its fingers hang over the
   line, 4px of its 42 under it. */
.frog-link {
  --z: 1;
  position: absolute;
  right: calc(8px / var(--z));
  bottom: calc(2px - 4px / var(--z));
  width: calc(72px / var(--z));
  height: calc(42px / var(--z));
  pointer-events: none;
}

@supports (zoom: tan(atan2(1cqw, 1px))) {
  .frog-link {
    --z: var(--zoom);
  }
}

.frog {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: light-dark(#5e842b, #90c05b);
}

/* The pointer finds the frog at rest, never its pixels: a paw lifted by the wave would make the
   pointer leave the link and enter it again, and the frog wave once more. */
.frog-link::before {
  content: "";
  position: absolute;
  inset: calc(18px / var(--z)) calc(8px / var(--z)) 0;
  pointer-events: auto;
  cursor: pointer;
}

.frog path {
  stroke: none;
}

/* alve.no's colours (site/style.css), with the board's texture mean for its fill. */
.frog .line {
  fill: currentColor;
}

.frog .fill {
  fill: var(--bounce);
}

.frog .eyes {
  fill: light-dark(#fbfbf8, #e4e4e1);
}

.frog .pupils {
  fill: #111210;
}

.frog .speech {
  fill: var(--text);
}

.frog .tongue {
  fill: light-dark(#e0567f, #f28bad);
}

.frog .beer {
  fill: light-dark(#edb345, #c8942c);
}

.frog .lids {
  display: none;
}

/* The logo, Hake: "avtavle" with the v as a filled box with a tick cut out of it. What stands
   beside it in the top row is sized in em of the logo. */
.top {
  display: flex;
  align-items: baseline;
  gap: .4em;
  font-size: var(--size-logo);
}

/* The front page's logo is the same link inside an h1. */
.top .logo {
  display: flex;
  font-size: 1em;
  line-height: 1;
}

.mark {
  display: flex;
  align-items: baseline;
  color: var(--soft);
  font-size: 1em;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.01em;
  text-decoration: none;
}

a.mark:hover {
  color: var(--edge);
}

.cellm {
  position: relative;
  display: inline-flex;
  justify-content: center;
  width: .74em;
  margin: 0 .05em 0 .04em;
}

.cellm .ghost {
  visibility: hidden;
}

/* The box in mark.html has corners as round as the ends of the letters, .066em. Its rx and ry
   differ, as this width and this height stretch its 40 units by .74 / .88. */
.cellbox {
  position: absolute;
  left: 0;
  top: .13em;
  width: 100%;
  height: .88em;
  overflow: visible;
}

.beta {
  color: var(--muted);
  font-size: .65em;
  font-weight: 800;
}

/* The theme switch at the right end of the logo's row. */
.top .theme {
  display: grid;
  place-items: center;
  align-self: center;
  width: 44px;
  height: 44px;
  margin: -11px -11px -11px auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.top .new + .theme {
  margin-left: 2px;
}

.top .theme:hover {
  color: var(--text);
}

.top .theme svg {
  grid-area: 1 / 1;
  width: 16px;
  height: 16px;
}

/* The icon shows the theme in use, whether the switch or the system chose it. */
.theme .moon,
:root[data-theme="dark"] .theme .sun {
  display: none;
}

:root[data-theme="dark"] .theme .moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme .sun {
    display: none;
  }

  :root:not([data-theme="light"]) .theme .moon {
    display: block;
  }
}

/* The parts of a widget's SVG: an icon's lines, a chalk stroke, a box laid over its button, and the
   box's outline and fills. */
.stroke {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chalk {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.box {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.line {
  fill: none;
  stroke: var(--line);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.line.dash {
  stroke-dasharray: 4 5;
}

.fill {
  fill: var(--fill);
  stroke: none;
}

.ring path {
  stroke: var(--chosen);
}

/* The words with an icon and no box: Beskrivelse, Tittel, Fjern alle and the lines that add one
   more. */
.sub,
.pmore {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--size-small);
  font-weight: 800;
  cursor: pointer;
}

.pmore {
  gap: 6px;
  padding: 0 6px 0 2px;
}

.sub:hover,
.pmore:hover {
  color: var(--text);
}

.sub {
  align-self: flex-start;
}

/* Fjern alle at the right under the calendar or the dial, and what goes with it at the left. */
.clearall {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.clearall .clear {
  margin-left: auto;
}

.clearall .sub:disabled,
.clearmine:disabled {
  color: var(--closed);
  cursor: default;
}
