/* moln.js mounts the tool in a shadow root (:host) on #catman, so nothing inherits in
   from a page that embeds it, as with Site Outliner. Standalone (moln.html) the same
   tokens and body rules also style the page. Diagol Grotesk and Mono load on
   wishyouwerehere.se; standalone the system fonts stand in. */
:host { all: initial; display: block; }

:root, :host {
  color-scheme: dark;
  --paper: #11161c;
  --ink: #e8edf2;
  --muted: color-mix(in srgb, var(--ink) 60%, var(--paper));
  --line: color-mix(in srgb, var(--ink) 18%, var(--paper));
  --glass: color-mix(in srgb, var(--paper) 82%, transparent);
  --select: #5aaee6;
  --font-sans: 'Diagol Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; block-size: 100%; overflow: hidden; }
body, :host { background: var(--paper); color: var(--ink); font: 15px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased; }
/* The stage everything stands on: the whole window on the tool's own page */
.app { position: relative; block-size: 100dvh; overflow: hidden; background: var(--paper); }
#sky { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; display: block; cursor: grab; touch-action: none; }
#sky.grabbing { cursor: grabbing; }
#sky.pointing { cursor: pointer; }
/* On the ring round the circle: a turning arrow, to show it can be turned */
#sky.rotate { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 26 26'><g fill='none' stroke-linecap='round' stroke-linejoin='round'><path d='M20 13a7 7 0 1 1-2.1-5' stroke='%2311161c' stroke-width='4.5'/><path d='M20 13a7 7 0 1 1-2.1-5' stroke='white' stroke-width='2'/><path d='M19.5 3.5v5h-5' stroke='%2311161c' stroke-width='4.5'/><path d='M19.5 3.5v5h-5' stroke='white' stroke-width='2'/></g></svg>") 13 13, grab; }

button, input { font: inherit; color: inherit; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; }
button { cursor: pointer; padding: 0.2rem 0.75rem; }
button:hover { border-color: var(--ink); }
button[aria-pressed='false'] { opacity: 0.45; }
:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }
.hidden-label { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); }

.hud { position: absolute; z-index: 2; }
.top-left { inset-block-start: 1.25rem; inset-inline-start: 1.5rem; max-inline-size: 28rem; pointer-events: none; }
.top-left > * { pointer-events: auto; }
.brand { color: inherit; font: 500 0.75rem var(--font-mono); text-decoration: none; }
h1 { margin: 0.5rem 0 0; font-weight: 400; font-size: 2rem; letter-spacing: -0.03em; line-height: 1.1; }
.facts { margin: 0.25rem 0 0.75rem; color: var(--muted); font-size: 0.875rem; }
.find input { inline-size: 16rem; padding: 0.35rem 0.9rem; }

.top-right { inset-block-start: 1.25rem; inset-inline-end: 1.5rem; display: flex; gap: 0.6rem; align-items: center; }
.zoom { display: flex; gap: 0.3rem; }
.zoom button { min-inline-size: 2.25rem; }

.dot { flex: none; inline-size: 0.7rem; block-size: 0.7rem; border-radius: 50%; }
.hint { margin: 0; color: var(--muted); font-size: 0.8125rem; }

.bottom-right { inset-block-end: 1.25rem; inset-inline-end: 1.5rem; margin: 0; color: var(--muted); font-size: 0.75rem; max-inline-size: 24rem; text-align: end; }

.card { position: absolute; z-index: 3; inset-block-start: 4.5rem; inset-inline-end: 1.5rem; inline-size: 22rem; max-block-size: calc(100% - 6rem); overflow: auto; padding: 1rem 1.1rem; background: var(--glass); border: 1px solid var(--line); border-radius: 0.9rem; backdrop-filter: blur(8px); }
.card h2 { margin: 0; font-size: 1.5rem; font-weight: 400; letter-spacing: -0.02em; display: flex; align-items: center; gap: 0.5rem; }
.card h2 input { inline-size: 100%; font-size: 1.25rem; border-radius: 0.4rem; padding: 0.1rem 0.4rem; }
.card .kind { margin: 0.1rem 0 0.6rem; color: var(--muted); font: 0.75rem var(--font-mono); }
.card h3 { margin: 0.9rem 0 0.3rem; font: 500 0.75rem var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.card .close { position: absolute; inset-block-start: 0.6rem; inset-inline-end: 0.6rem; border: 0; font-size: 1.1rem; }
.bars { display: grid; gap: 0.2rem; }
.bar { display: grid; grid-template-columns: 7rem 1fr 2.5rem; gap: 0.5rem; align-items: center; font-size: 0.8125rem; }
.bar .track { block-size: 0.45rem; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar .fill { block-size: 100%; border-radius: 999px; }
.bar .num { font: 0.75rem var(--font-mono); color: var(--muted); text-align: end; }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chips button { font-size: 0.8125rem; padding: 0.1rem 0.6rem; }
.products { list-style: none; margin: 0; padding: 0; font-size: 0.8125rem; }
.products li { padding: 0.15rem 0; border-block-end: 1px solid color-mix(in srgb, var(--ink) 6%, transparent); }
.products .muted { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-block-start: 0.9rem; }
.actions .main { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.start { position: absolute; z-index: 4; inset: 0; display: grid; place-content: center; gap: 1rem; padding: 2rem; background: var(--paper); max-inline-size: 100%; overflow: auto; }
.start[hidden] { display: none; }
.start > * { max-inline-size: 34rem; }
.start h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); }
.start p { color: var(--muted); font-size: 1.0625rem; }
.demo { color: var(--select); }
.status { font: 0.8125rem var(--font-mono); min-block-size: 1.5em; }

@media (max-width: 48rem) {
  .card { inset-inline: 1rem; inline-size: auto; inset-block-start: auto; inset-block-end: 1rem; max-block-size: 55vh; }
  .tip { display: none; }
}

/* Products in a card are buttons that look like text */
.products .link, a.link { border: 0; background: none; padding: 0; text-align: start; color: var(--ink); cursor: pointer; text-decoration: none; }
.products .link:hover, a.link:hover { text-decoration: underline; }
.actions select { font: inherit; color: inherit; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.6rem; max-inline-size: 100%; }

/* The shop's address on the start screen */
.address { display: grid; gap: 0.4rem; }
.address label { font-weight: 500; }
.address .row { display: flex; gap: 0.4rem; }
.address input { flex: 1; min-inline-size: 0; padding: 0.55rem 1rem; font-size: 1.0625rem; }
.address button { padding-inline: 1.2rem; }
.address button:disabled { opacity: 0.5; cursor: progress; }
.address small { color: var(--muted); }
.start .main { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.card .note { margin: -0.3rem 0 0.4rem; color: var(--muted); font-size: 0.8125rem; }

/* Switching shop */
.facts .link { border: 0; background: none; padding: 0; margin-inline-start: 0.4rem; color: var(--select); font-size: inherit; cursor: pointer; }
.facts .link:hover { text-decoration: underline; }
.start .back { justify-self: start; }
.start .back[hidden] { display: none; }
.start .note { margin: 0; color: #ffd166; font-size: 0.875rem; }
.picks h2 { margin: 0 0 0.4rem; font: 500 0.75rem var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.picks[hidden] { display: none; }

/* The card: what it is, where it is, and a few plain actions */
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.9rem; margin: 0 0 0.4rem; font-size: 0.8125rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; }
.rows { list-style: none; margin: 0; padding: 0; font-size: 0.8125rem; }
.rows li { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; padding: 0.2rem 0; border-block-end: 1px solid color-mix(in srgb, var(--ink) 6%, transparent); }
.rows .link { border: 0; background: none; padding: 0; text-align: start; color: var(--ink); cursor: pointer; }
.rows .link:hover { text-decoration: underline; }
.rows .n { font: 0.75rem var(--font-mono); color: var(--muted); }
.card .hint { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.75rem; }
.card .note { margin: 0.4rem 0; }
.card h2 { padding-inline-end: 1.75rem; }

/* When the shop was fetched */
.fetched { margin: -0.6rem 0 0.75rem; color: var(--muted); font-size: 0.75rem; }
.fetched[hidden] { display: none; }
.fetched .link { border: 0; background: none; padding: 0; color: var(--select); font-size: inherit; cursor: pointer; }
.fetched .link:hover { text-decoration: underline; }

/* Navigering or Struktur, each with a line on what it shows */
.lenses { display: grid; gap: 0.35rem; margin-block-start: 0.25rem; max-inline-size: 19rem; }
.lenses[hidden] { display: none; }
.lenses button { display: grid; gap: 0.1rem; padding: 0.5rem 0.8rem; text-align: start; border-radius: 0.6rem; background: var(--glass); }
.lenses button[aria-pressed='true'] { border-color: var(--ink); opacity: 1; }
.lenses button[aria-pressed='false'] { opacity: 0.6; }
.lenses button[aria-pressed='false']:hover { opacity: 1; }
.lens-name { font-weight: 500; font-size: 0.875rem; }
.lenses button[aria-pressed='true'] .lens-name::before { content: ''; display: inline-block; inline-size: 0.5rem; block-size: 0.5rem; margin-inline-end: 0.45rem; border-radius: 50%; background: var(--select); vertical-align: 0.08em; }
.lens-text { color: var(--muted); font-size: 0.75rem; line-height: 1.35; }
.top-right .find input { inline-size: 14rem; }
.human { max-inline-size: 19rem; }

/* Cirkel or Lista: one pressed, the other quiet */
.shapes { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; gap: 2px; background: var(--glass); font-size: 0.8125rem; }
.shapes button { border: 0; background: none; }
.shapes button[aria-pressed='true'] { background: var(--ink); color: var(--paper); opacity: 1; }
.shapes button[aria-pressed='false'] { opacity: 0.7; }

/* The list's levels: a quiet button over each column, to close or open all of it */
.levels { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.levels[hidden] { display: none; }
.levels button { position: absolute; inset-block-start: 0; inset-inline-start: 0; pointer-events: auto; inline-size: 1.5rem; block-size: 1.5rem; padding: 0; display: grid; place-items: center; color: var(--muted); opacity: 0.6; translate: -50% 0; }
.levels button:hover, .levels button:focus-visible { opacity: 1; color: var(--ink); }
.levels button[hidden] { display: none; }
.levels svg { inline-size: 0.9rem; block-size: 0.9rem; }

/* What keeps the tool from collecting anything, beside the field, as in Site Outliner */
.address .privacy { margin: 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }

/* Embedded (data-base), wishyouwerehere.se's page carries the name and the heading,
   and the field lines up with the site's heading through its --rutnat-indrag, which
   inherits into the shadow root */
:host([data-base]) :is(.brand, .start .name, .start .lede) { display: none; }
/* Once a shop is read (data-state="result"), the stage fills the window below the
   site's menu, and a little less than the window, so some of the page always shows
   to scroll it by: the stage keeps the wheel and the fingers for itself */
:host([data-base][data-state='result']) .app { block-size: calc(100dvh - 4rem); }
/* Until a shop is read, only the start shows there, in the page's flow */
:host([data-base]:not([data-state='result'])) .app { block-size: auto; overflow: visible; background: none; }
:host([data-base]:not([data-state='result'])) .app > :not(.start),
:host([data-base]:not([data-state='result'])) #sky { display: none; }
:host([data-base]:not([data-state='result'])) .start { position: static; place-content: start; padding: 0 var(--rutnat-indrag, 0) 3.75rem; background: none; overflow: visible; }

/* Narrow, as on a phone: the shop's name and the lenses keep to the top, as two
   short buttons without their lines, and finding, the shape and zooming go to the
   bottom, so the tree has the middle. The card stands above them. */
@media (max-width: 48rem) {
  .top-left { inset-block-start: 0.9rem; inset-inline: 1rem; max-inline-size: none; }
  h1 { font-size: 1.5rem; }
  .facts { margin-block-end: 0.5rem; font-size: 0.8125rem; }
  .lenses { grid-auto-flow: column; justify-content: start; max-inline-size: none; }
  .lenses button { padding: 0.25rem 0.75rem; border-radius: 999px; }
  .lens-text { display: none; }
  .top-right { inset-block: auto 0.9rem; inset-inline: 1rem; flex-wrap: wrap; justify-content: space-between; }
  .top-right .find { flex: 1; min-inline-size: 7rem; }
  .top-right .find input { inline-size: 100%; }
  .card { inset-block-end: 4rem; max-block-size: 50%; }
}
