/* bolag.matigo.se
   The material is the green columnar accounting pad: pale paper, green
   column rules, blue-black ink, and red ink kept for losses and warnings. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  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: "Schibsted Grotesk";
  src: url("fonts/schibsted-grotesk-latin-ext.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, 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;
}

:root {
  --paper: #f5f8f1;
  --box: #fdfefb;
  --ledger: #e3edda;
  --rule-faint: #cadcbf;
  --rule: #a9c7a0;
  --rule-strong: #6f9a68;
  --ink: #1c2638;
  --ink-soft: #4e5a63;
  --green-ink: #2d6a48;
  --red-ink: #b42318;

  --content: 44rem;
  --gutter: 16px;

  /* Scale from The Elements of Typographic Style: 14 16 18 21 24 36 48 60 */
  --t-small: 0.875rem;
  --t-note: 1rem;
  --t-body: 1.125rem;
  --t-lead: 1.3125rem;
  --t-h2: 1.5rem;
  --t-digit: clamp(1.75rem, 6vw, 2.25rem);
  --t-display: clamp(2.25rem, 7vw, 3.75rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111813;
    --box: #182119;
    --ledger: #162117;
    --rule-faint: #263628;
    --rule: #35503b;
    --rule-strong: #52795a;
    --ink: #e4ebe2;
    --ink-soft: #a2b0a5;
    --green-ink: #82cc9f;
    --red-ink: #ff9384;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Schibsted Grotesk", system-ui, sans-serif;
  font-size: var(--t-body);
  line-height: 1.5;
}

h1, h2, p, dl, dd, ol, ul, blockquote, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--green-ink);
  outline-offset: 3px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -4rem;
  padding: 0.5rem 0.75rem;
  background: var(--ink);
  color: var(--paper);
}
.skip:focus { top: 0.5rem; }

/* Page frame: one centred column; bands run edge to edge. */

.site,
main > *:not(.band, .company),
.company > *:not(.band) {
  width: min(var(--content), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

header.site {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  padding-block: 1.25rem;
}

.wordmark {
  font-weight: 700;
  font-size: var(--t-body);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.wordmark span { font-weight: 400; color: var(--ink-soft); }

footer.site {
  margin-top: 5rem;
  padding-block: 1.5rem 3rem;
  border-top: 1px solid var(--rule-faint);
  color: var(--ink-soft);
  font-size: var(--t-small);
  max-width: min(var(--content), 100% - 2 * var(--gutter));
}
footer.site p + p { margin-top: 0.25rem; }

h2 {
  font-size: var(--t-h2);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.note { color: var(--ink-soft); font-size: var(--t-note); }

/* Search */

.search {
  position: relative;
  display: flex;
  border-radius: 6px;
}

/* One focus ring around the field and its button, so it never sticks out
   past the button the way a ring on the field alone does. */
.search input:focus-visible { outline: none; }
.search:has(input:focus-visible) {
  outline: 3px solid var(--green-ink);
  outline-offset: 2px;
}

.search input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: var(--box);
  border: 2px solid var(--ink);
  border-right: 0;
  border-radius: 6px 0 0 6px;
  padding: 0.5rem 0.75rem;
}
.search input::placeholder { color: var(--ink-soft); opacity: 1; }

.search button {
  font: inherit;
  font-weight: 650;
  color: var(--paper);
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 0 6px 6px 0;
  padding: 0 1.25rem;
  cursor: pointer;
}
.search button:hover { background: var(--green-ink); border-color: var(--green-ink); }

.search-large input { font-size: var(--t-lead); padding: 0.8rem 1rem; }
.search-large button { font-size: var(--t-lead); padding-inline: 1.75rem; }

.search-compact { flex: 1 1 18rem; max-width: 24rem; font-size: var(--t-note); }

/* Suggestions while typing */

.suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: min(30rem, 65vh);
  overflow-y: auto;
  background: var(--box);
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-size: var(--t-note);
  line-height: 1.35;
}
.suggestions li {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 1rem;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--rule-faint);
  cursor: pointer;
}
.suggestions li:last-child { border-bottom: 0; }
.suggestions li:hover,
.suggestions li[aria-selected="true"] { background: var(--ledger); }
.suggestions li[aria-selected="true"] { box-shadow: inset 4px 0 0 var(--green-ink); }

.suggestion-name { font-size: var(--t-body); overflow-wrap: anywhere; }
.suggestion-name mark {
  background: none;
  color: inherit;
  font-weight: 650;
}
.suggestion-status { justify-self: end; font-size: var(--t-small); padding-top: 0.2em; }
.suggestion-about { grid-column: 1 / -1; color: var(--ink-soft); font-size: var(--t-small); }

/* Start page */

.lookup { padding-top: clamp(2.5rem, 14vh, 8rem); }
.lookup h1 {
  font-size: var(--t-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1.5rem;
  text-wrap: balance;
}
.lookup h1 label { cursor: text; }
.lookup-scope {
  margin-top: 1rem;
  color: var(--ink-soft);
  max-width: 34em;
}

.lookup-searched { padding-top: clamp(1.5rem, 5vh, 3rem); }
.lookup-searched h1 { font-size: var(--t-h2); letter-spacing: -0.01em; margin-bottom: 1rem; }
.lookup-searched .lookup-scope { display: none; }
.lookup-searched h1.missing { font-size: var(--t-lead); font-weight: 600; line-height: 1.35; max-width: 32em; }

.results { margin-top: 2.5rem; }
.results h2 { font-size: var(--t-note); font-weight: 600; color: var(--ink-soft); margin-bottom: 0.5rem; }
.results h2.results-message { font-size: var(--t-body); font-weight: 400; color: var(--ink); max-width: 36em; }
.results-more { margin-top: 1rem; color: var(--ink-soft); font-size: var(--t-note); }

.hits { border-top: 2px solid var(--rule-strong); }

.hit {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name orgnr"
    "meta standing";
  column-gap: 1.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule-faint);
  text-decoration: none;
}
.hit-name { grid-area: name; font-weight: 600; overflow-wrap: anywhere; }
.hit:hover .hit-name { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
.hit-meta { grid-area: meta; color: var(--ink-soft); font-size: var(--t-note); }
.hit-orgnr { grid-area: orgnr; justify-self: end; }
.hit-standing { grid-area: standing; justify-self: end; font-size: var(--t-note); }

.tone-ok { color: var(--green-ink); }
.tone-warn { color: var(--red-ink); }
.tone-gone { color: var(--ink-soft); }

/* The ledger band: the accounting pad, edge to edge. */

.band {
  margin-top: 3.5rem;
  padding-block: 2rem 2.5rem;
  background: var(--ledger);
  border-block: 1px solid var(--rule);
}
.band > * {
  width: min(var(--content), 100% - 2 * var(--gutter));
  margin-inline: auto;
}
.band h2 { margin-bottom: 1rem; }

.ledger-scroll { overflow-x: auto; }

.ledger {
  width: 100%;
  border-collapse: collapse;
}
.ledger caption {
  caption-side: top;
  text-align: right;
  color: var(--ink-soft);
  font-size: var(--t-small);
  padding-bottom: 0.25rem;
}
.ledger th, .ledger td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--rule-faint);
  vertical-align: baseline;
}
.ledger th[scope="row"], .ledger th[scope="rowgroup"] { text-align: left; font-weight: 400; padding-left: 0; }
.ledger th[scope="col"] { text-align: right; vertical-align: bottom; font-weight: 650; }
.ledger thead th, .ledger thead td { border-bottom: 2px solid var(--rule-strong); }
.ledger thead th:first-child { text-align: left; padding-left: 0; }

/* Column rules: a double rule after the labels, single rules between years. */
.ledger td { border-left: 1px solid var(--rule); }
.ledger thead td { border-left: 0; }
.ledger tr > :nth-child(2) { border-left: 3px double var(--rule-strong); }

/* Tabular figures widen the comma and full stop in this face, so they are
   kept to columns of whole numbers. */
.ledger .num { text-align: right; white-space: nowrap; }
.ledger-full .num, .hit-orgnr, .digit { font-variant-numeric: tabular-nums; }
.ledger .neg { color: var(--red-ink); }

.ledger .year { display: block; font-size: var(--t-body); }
.ledger .period { display: block; font-weight: 400; font-size: var(--t-small); color: var(--ink-soft); white-space: nowrap; }

.ledger tr.section th {
  padding: 1.5rem 0 0.4rem;
  font-weight: 650;
  border-bottom: 1.5px solid var(--rule-strong);
}
.ledger tbody:first-of-type tr.section th { padding-top: 0.75rem; }

.ledger tr.total > * { font-weight: 650; border-top: 1px solid var(--ink); }

.ledger-full th[scope="row"] { min-width: 13rem; }
.ledger-full th[scope="col"] { width: 9.5rem; }

.ledger-compact th[scope="row"] a { font-weight: 600; text-decoration: none; }
.ledger-compact th[scope="row"] a:hover { text-decoration: underline; }
.ledger-compact .row-note { display: block; font-size: var(--t-small); color: var(--ink-soft); }
.ledger-compact td { width: 9rem; }

/* Company page */

.company { display: contents; }

.company-name {
  margin-top: clamp(1.5rem, 6vh, 3.5rem);
  font-size: var(--t-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

/* The organisationsnummer in comb boxes, as on a paper form. Clicking copies it. */

.orgnr {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 1rem;
  margin-top: 1.25rem;
  padding: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: copy;
}

.orgnr-boxes {
  display: inline-flex;
  align-items: flex-end;
  font-size: var(--t-digit);
  font-weight: 500;
  line-height: 1;
}
.comb {
  display: inline-flex;
  background:
    linear-gradient(var(--rule-strong), var(--rule-strong)) right bottom / 1.5px 0.45em no-repeat,
    var(--box);
  border-bottom: 2px solid var(--rule-strong);
}
.digit {
  width: 1.05em;
  padding: 0.3em 0 0.22em;
  text-align: center;
  background: linear-gradient(var(--rule-strong), var(--rule-strong)) left bottom / 1.5px 0.45em no-repeat;
}
.dash { width: 0.7em; text-align: center; color: var(--ink-soft); padding-bottom: 0.22em; }

.orgnr-hint {
  font-size: var(--t-note);
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  padding-bottom: 0.3em;
}
.orgnr:hover .comb { border-bottom-color: var(--ink); }
.orgnr:hover .orgnr-hint { color: var(--ink); text-decoration-thickness: 2px; }
.orgnr.is-copied .orgnr-hint { color: var(--green-ink); text-decoration: none; }

.standing {
  margin-top: 1.75rem;
  font-size: var(--t-lead);
  line-height: 1.4;
  max-width: 34em;
}
.standing strong { font-weight: 700; }
.standing.tone-ok, .standing.tone-gone { color: var(--ink); }
.standing.tone-ok strong { color: var(--green-ink); }
.standing.tone-gone strong { color: var(--ink-soft); }

.facts {
  margin-top: 2rem;
  border-top: 1px solid var(--rule);
}
.facts > div {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.25rem 1.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule-faint);
}
.facts dt { color: var(--ink-soft); }
.facts .industry { display: block; }
.facts .code { color: var(--ink-soft); font-size: var(--t-note); white-space: nowrap; }

.purpose, .names { margin-top: 3rem; }
.purpose h2, .names h2 { margin-bottom: 0.75rem; }

.purpose blockquote {
  font-size: var(--t-lead);
  line-height: 1.45;
  max-width: 36em;
  hanging-punctuation: first;
}
.purpose blockquote p::before { content: "”"; margin-left: -0.45em; display: inline-block; width: 0.45em; }
.purpose blockquote p::after { content: "”"; }
.purpose .note { margin-top: 0.5rem; }

.names li { padding: 0.6rem 0; border-bottom: 1px solid var(--rule-faint); }
.names li:first-child { border-top: 1px solid var(--rule); }
.other-name { display: block; font-weight: 600; }
.other-purpose { display: block; margin-top: 0.15rem; }

.accounts .signed { margin-top: 1rem; color: var(--ink-soft); font-size: var(--t-note); }
.accounts .empty { max-width: 36em; }

@media (max-width: 40rem) {
  :root { --t-lead: 1.1875rem; }
  .facts > div { grid-template-columns: 1fr; }
  .search-compact { max-width: none; }
  .hit { grid-template-columns: 1fr; grid-template-areas: "name" "orgnr" "meta" "standing"; }
  .hit-orgnr, .hit-standing { justify-self: start; }
  .hit-orgnr { font-size: var(--t-note); color: var(--ink-soft); }
  .ledger th, .ledger td { padding-inline: 0.5rem; }
  .ledger-full th[scope="row"] { min-width: 10rem; }
  .ledger-full th[scope="col"] { width: auto; min-width: 7rem; }
  .ledger-compact td { width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
