/* SPDX-License-Identifier: AGPL-3.0-or-later */
/* svrngs's look, one file for both its pages: the home page serves it
   (home.rs, LOOK) and the group's page is given the same file
   (scripts/build-web.sh, beside question.js). Neither page runs an inline
   style; the home page's policy forbids one.

   Its one rule: nothing imitates anything else. A page brings what a browser
   does best: the system's own fonts and colours, its own elements, plain
   rules. Warmth is colour, by the names the browser already knows. It styles
   the elements the pages already make, so a page needs no class to wear it. */

:root {
  /* The browser's own colours, which follow the person's light or dark setting. */
  color-scheme: light dark;
  --paper: Canvas;
  --ink: CanvasText;
  --link: LinkText;
  --visited: VisitedText;
  /* Warmth: named colours, each read in black, in either setting. */
  --band: salmon;
  --lit: yellow;
  --warn: tomato;
  --on-colour: black;
  --rule: 3px solid var(--ink);
  --hair: 1px solid var(--ink);
  --face: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* What a page hides stays hidden, whatever display a rule here gives it. */
[hidden] { display: none !important; }

body { max-width: 64rem; margin: 0 auto; padding: 0 1rem 3rem; background: var(--paper); color: var(--ink); font: 1rem/1.45 var(--face); }

/* The page's name, in a band of colour. */
h1 { margin: 1.5rem 0; padding: 1.25rem 1.25rem 1rem; border: var(--rule); background: var(--band); color: var(--on-colour); font-size: clamp(2rem, 7vw, 5.5rem); font-weight: 900; line-height: 0.9; letter-spacing: -0.045em; overflow-wrap: anywhere; }
h2 { margin: 0 0 0.5rem; font-size: 1.75rem; font-weight: 900; line-height: 1.1; letter-spacing: -0.03em; }
section { border-top: var(--rule); padding: 1rem 0 1.25rem; }
p { max-width: 72ch; }

a { color: var(--link); }
a:visited { color: var(--visited); }
/* Yellow means "do this", a form's own button, below, and one thing more:
   the door's doorbell, a person whose computer is on, lit as a window is
   when someone is home. So a hover is drawn in the page's ink, never lit. */
a:hover, button:hover { background: var(--ink); color: var(--paper); }
/* The focus, and the cell a person's popover sent the page to (`:target`). */
:focus-visible, div.index > ul > li:has(:target) { outline: 3px solid var(--link); outline-offset: 2px; }

button { margin: 0.25rem 0.5rem 0.25rem 0; padding: 0.35rem 0.8rem; border: var(--rule); border-radius: 0; background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
/* A form's own button is the one to press. */
form button:not([type="button"]) { background: var(--lit); color: var(--on-colour); }
/* A field is a box to type in, said as plainly as a button. A tick box is
   none: drawn 12ch wide, its tick sat centered a column from its words. */
input:not([type="checkbox"]) { min-width: 12ch; margin: 0 0.5rem 0.25rem 0.25rem; padding: 0.35rem 0.5rem; border: var(--rule); border-radius: 0; background: var(--paper); color: var(--ink); font: inherit; }
/* A group of boxes under the sentence that says what ticking them does (ui/shelf.js): no frame, the sentence as wide as a paragraph. */
fieldset { margin: 0; padding: 0; border: 0; }
legend { max-width: 72ch; padding: 0; }
/* A label wraps as one piece with the field it names. */
label { display: inline-block; font-weight: 600; }

/* A list is rows between rules; two lists in a row share the rule between them. */
/* No marker, as `list-style-type: ""`, not `none`: Safari tells VoiceOver
   that a list styled `none` is no list, and these are lists. */
ul { margin: 0.5rem 0; padding: 0; list-style-type: ""; }
ul:not(:empty) { border-top: var(--hair); }
ul + ul { margin-top: -0.5rem; border-top: 0; }
li { padding: 0.5rem 0; border-bottom: var(--hair); }

/* svrngs's own words, as a machine says them: where a thing is, what is being read, a line to type. */
code, pre, kbd, .said, .folder, .address { font-family: var(--mono); }
code { font-size: 0.92em; overflow-wrap: anywhere; }
pre { padding: 0.75rem; border: var(--rule); white-space: pre-wrap; word-break: break-word; }
pre:empty { display: none; }

/* A person's own words, quoted: the lender's, when an app asks. */
blockquote { margin: 1rem 0; padding: 0.5rem 1rem; border-left: 0.5rem solid var(--ink); font-size: 1.25rem; font-style: italic; }

details > summary { font-weight: 700; cursor: pointer; }
/* A heading folded under its own summary ("What acts as you"), on its line. */
summary > h2 { display: inline; }

/* A group's colour, derived from its id by the page (home.js `section`; the
   operator, "Derived from the group"): no setting, nothing to choose. Each a
   name the browser knows, read in black. */
section[data-colour="0"] { --group: salmon; }
section[data-colour="1"] { --group: gold; }
section[data-colour="2"] { --group: lightgreen; }
section[data-colour="3"] { --group: skyblue; }
section[data-colour="4"] { --group: plum; }
section[data-colour="5"] { --group: orange; }
section[data-colour="6"] { --group: aquamarine; }
section[data-colour="7"] { --group: pink; }
section[data-colour="8"] { --group: khaki; }
section[data-colour="9"] { --group: lightsalmon; }
section[data-colour="10"] { --group: palegreen; }
section[data-colour="11"] { --group: lightskyblue; }
section[data-colour] > h2 { padding: 0.25rem 0.5rem; border: var(--rule); background: var(--group); color: var(--on-colour); }
:is(h1, h2) small { font-size: 1rem; font-weight: 600; letter-spacing: 0; }

/* The door: each person a cell, a doorbell on a building's panel, lit while
   their computer answers, drawn off when it did not, a phone's marked; the
   words say each, not the colour. */
ul.door, div.index > ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.5rem; border: 0; }
ul.door > li, div.index > ul > li { padding: 0.5rem; border: var(--hair); }
ul.door > li { font-weight: 700; }
ul.door > li > small { display: block; font-weight: 400; }
ul.door > li.on { border: var(--rule); background: var(--lit); color: var(--on-colour); }
ul.door > li.off { border-style: dashed; color: GrayText; }
ul.door > li.phone { border-style: dotted; }
/* On the home page's group a person is one line, the name with how they
   stand beside it in the same small words, and a cell is narrower, so 28
   people are four rows where they were six of two lines: who is here is
   read at a glance, above what they share. The words still say each; a
   long name or standing wraps inside its cell. The screen (`body.screen`)
   keeps its big cells, and the phone's page, which has no `#home`, its own. */
body:not(.screen) #home ul.door { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: 0.35rem; }
body:not(.screen) #home ul.door > li { padding: 0.15rem 0.4rem; overflow-wrap: anywhere; }
body:not(.screen) #home ul.door > li > small { display: inline; }
/* "did not answer" in the page's own ink: the system's gray on the page is
   under 4.5 to 1 (#808080 on white, 3.9), and the dashed border and the
   words already say it. */
body:not(.screen) #home ul.door > li.off { color: inherit; }

/* The home page's index: what a group shares, in the door's cells, each
   grid under the sentence true of everything in it. A grid fills the width
   it has, so the same page holds eight things and eighty; a long name
   breaks inside its cell, never widens the page. Two grids in a row keep
   the gap between cells. */
div.index > ul + ul { margin-top: 0; }
div.index > ul > li { overflow-wrap: anywhere; }
/* A cell's name is its one way in (lend-name.js), drawn heaviest. */
div.index > ul > li > a[id^="at-"] { font-weight: 800; }
div.index > ul > li > :is(span, form) button { margin: 0; }
/* Forty things are a screen of cells, so a cell is as tight as the door's:
   a line of words and little around it, its Play no taller than the line. */
div.index > ul { grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: 0.35rem; }
div.index > ul > li { padding: 0.2rem 0.4rem; }
div.index > ul > li > span button { padding: 0 0.6rem; }
div.index > p { margin: 0.6rem 0 0.4rem; }
/* The cell that asks a yes says more than a name, and may list what it
   opens, each with a tick: it takes a row of its own, its button beside its
   words. It is drawn last in its grid (index.js `place`), so no row before
   it is left part empty, and cells are read and tabbed in the order drawn. */
div.index > ul > li:has(form) { grid-column: 1 / -1; }
div.index > ul > li > form { display: inline; }

/* A table, the phone page's index: a rule under each row. */
table { width: 100%; margin: 0.5rem 0; border-collapse: collapse; }
th, td { padding: 0.4rem 0.5rem 0.4rem 0; border-bottom: var(--hair); text-align: left; vertical-align: top; }
thead th { border-bottom: var(--rule); }

/* What went wrong, and what was just done (running-here.js `Found`, lent). */
.bad { background: var(--warn); color: var(--on-colour); }
.lit { border: var(--rule); background: var(--lit); color: var(--on-colour); }
p.bad, p.lit { padding: 0.25rem 0.5rem; }
p.bad:empty { display: none; }

/* The group's page (web/index.html): its forms one field under another, and
   each thing in its index (`tbody#lent`, web/page/lent-index.js) opened by a
   button as wide as its cell. The home page's "What you lend" is a section
   `#lent`, whose buttons this is not for. */
form { display: grid; gap: 0.5rem; justify-items: start; }
tbody#lent button { width: 100%; text-align: left; }
#line { user-select: all; }

/* A group on a screen (home.js `screen`), read across a room: the group's
   band across the top with its count, its door down the left two thirds,
   what arrived since the screen opened down the last third, the legend
   under both (the Draft 2 canvas's frames 8-10). Sized by the screen, so a
   TV, a laptop and a projector each fill theirs. */
body.screen { max-width: none; height: 100vh; margin: 0; padding: 0; overflow: hidden; font-size: 1.4vw; }
body.screen #intro, body.screen #again { display: none; }
body.screen main, body.screen section { height: 100%; }
body.screen section { display: grid; grid-template: "name count" auto "door since" minmax(0, 1fr) "foot foot" auto / 2fr 1fr; padding: 0; border: 0; }
body.screen section > h2 { grid-area: name; margin: 0; padding: 1.4vw 2vw 1vw; border: 0; border-bottom: var(--rule); font-size: 5.5vw; line-height: 0.85; letter-spacing: -0.055em; }
body.screen section > h2 small { font-size: 1.1vw; }
body.screen section > p { grid-area: count; display: flex; align-items: flex-end; max-width: none; margin: 0; padding: 1.4vw 2vw 1.2vw; border-bottom: var(--rule); background: var(--group); color: var(--on-colour); font-family: var(--mono); font-size: 1.3vw; }
body.screen section > div { grid-area: door; overflow: hidden; padding: 1.2vw 1.4vw; border-right: var(--rule); }
body.screen ul.door { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: 7.4vw; gap: 0.6vw; margin: 0; }
body.screen ul.door li { position: relative; overflow: hidden; padding: 0.5vw 0.6vw; border-width: 3px; font-size: 1.25vw; line-height: 1.2; }
body.screen ul.door li strong { display: block; margin-bottom: 0.3vw; font-size: 1.75vw; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
body.screen ul.door li a { margin-right: 0.4vw; font-weight: 600; }
body.screen ul.door li.on a { color: var(--on-colour); }
body.screen ul.door li small { position: absolute; bottom: 0.5vw; left: 0.6vw; font-family: var(--mono); font-size: 0.85vw; }
body.screen aside { grid-area: since; overflow: hidden; padding: 1.2vw 1.4vw; }
body.screen aside h2 { margin: 0 0 0.3vw; font-size: 2.1vw; }
body.screen aside > p, body.screen footer { font-family: var(--mono); font-size: 0.85vw; }
body.screen aside ol { margin: 0.4vw 0 0; padding: 0; list-style: none; border-top: var(--rule); }
body.screen aside li { padding: 0.25vw 0; font-size: 1.3vw; }
body.screen aside ol + p { font-family: var(--face); font-size: 1.35vw; }
body.screen aside ol:not(:empty) + p { display: none; }
body.screen time { display: inline-block; min-width: 4.6em; font-family: var(--mono); font-size: 0.8em; }
body.screen mark { padding: 0 0.3em; background: hotpink; color: var(--on-colour); font-family: var(--mono); font-size: 0.65em; font-weight: 400; vertical-align: 0.2em; }
body.screen footer { grid-area: foot; display: flex; justify-content: space-between; gap: 2vw; padding: 0.6vw 2vw; border-top: var(--rule); }
body.screen footer p { max-width: none; margin: 0; }

/* "What acts as you": a Stop beside its line (home.js `reach`). */
#acts form { display: inline; }

/* The address to keep (question.js `keeping`): its own line, in the
   address's face, broken anywhere, as a label is 62 letters long. */
small.keep { display: block; font-family: var(--mono); overflow-wrap: anywhere; }

/* "Address" in a cell of the index (wifi.js `Address`): a small button,
   always there to be seen, pressed and spoken to, at the right of its
   cell's first line. The cell keeps that room free of words, so no name
   wraps under it and no cell grows a line for it; it is 24px tall at
   least, a target a finger or a switch can take. The popover it opens is
   the browser's own, over the page, closed on Escape or a press outside
   it: the page's own box, no wider than the window. */
div.index > ul > li:has(> button[popovertarget]) { position: relative; padding-right: 4.6rem; }
div.index > ul > li > button[popovertarget] { position: absolute; top: 0.2rem; right: 0.4rem; min-height: 1.5rem; margin: 0; padding: 0 0.3rem; border: var(--hair); font-size: 0.8rem; font-weight: 400; }
/* A person in the home page's door is pressed (people.js `Person`): the
   name is a button drawn as the name it was, and the whole cell takes the
   press. Its focus is drawn round the cell in the page's ink, since the
   link's blue on a lit cell's yellow is 2.2 to 1 in a dark window. Its
   popover sits at the window's foot, so the cell one of its links goes to,
   scrolled to the top, is not under it. */
#home ul.door > li > button { margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; }
#home ul.door > li > button::after { content: ""; position: absolute; inset: 0; cursor: pointer; }
#home ul.door > li > button:focus-visible { outline: 0; }
#home ul.door > li:has(> button:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
#home ul.door > li { position: relative; }
[popover].person { inset: auto 0 0.5rem; margin: 0 auto; color: var(--ink); font-weight: 400; }
[popover] { box-sizing: border-box; max-width: min(36rem, calc(100vw - 2rem)); padding: 0.75rem 1rem; border: var(--rule); background: var(--paper); color: var(--ink); overflow-wrap: anywhere; }

/* B, the home page's layout: the overview says what the page is, a group's
   banner heads its own, and only This computer has the page's foot. */
body.layout-b h1 { margin-bottom: 0.75rem; padding: 0.75rem; font-size: 2.25rem; line-height: 1; }
body.layout-b .folder, body.layout-b .address { overflow-wrap: anywhere; }
/* A group's page is headed by its banner under the navigation's rule: a
   second rule above the banner would rule off nothing. */
body.layout-b section[data-colour] { border-top: 0; padding-top: 0; }
.grouped-nav { margin: 1.5rem 0; border-block: var(--rule); padding: 0.5rem 0; }
.grouped-nav p { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.grouped-nav a { display: inline-block; padding: 0.25rem 0; }
.grouped-nav a[aria-current="page"] { font-weight: 800; text-decoration-thickness: 3px; }
.group-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 0.75rem; border: 0 !important; }
.group-list li { padding: 0.75rem; border: var(--hair); }
.group-list a { font-weight: 700; }
.group-list small { display: block; }
/* The invitation buttons (group-links.js) are one row that wraps: the
   paragraph each pair is in runs on with the next, where a paragraph of
   its own a pair, 72ch wide, stacked four buttons in three rows. What an
   open invitation says keeps its own lines above them. */
.publication, .publication > p:last-child, .publication + p { display: inline; }
/* An invitation's QR code (group-links.js `ways`): dark on light in either
   setting, as a camera reads one, and wide enough for a phone across a
   table to read it, a phone's width on a phone. */
.publication svg.qr { display: block; width: min(100%, 24rem); height: auto; margin: 0.5rem 0; border: var(--rule); background: white; }
.publication svg.qr path { fill: black; }
.group-place { margin: 1rem 0; padding: 0.75rem 0; border-top: var(--hair); }
.group-place > summary { font-size: 1.1rem; }
/* "Add an app" opens straight to the shelf: its own heading, in other words, is the fold's. */
.group-place > section > h3:first-child { display: none; }
.grouped-notice { border-left: 0.3rem solid var(--link); padding-left: 0.75rem; }
body.layout-b #again { display: none; }
body.layout-b:has(.grouped-nav[data-view="computer"]) #again { display: block; }
body.layout-b:has(.grouped-nav:not([data-view="groups"])) #intro { display: none; }
/* With `#intro` hidden, a group's page and This computer would have no
   first heading for a screen reader to land on, so each one's own is an h1
   (group.js `Group`, grouped.js `Context`) and a group's headings under
   its banner are h2. Each is drawn as it was while it was an h2 or an h3:
   the level is for whoever cannot see the size. */
body.layout-b #home > h1, body.layout-b section[data-colour] > h1 { margin: 0 0 0.5rem; padding: 0; border: 0; background: none; color: inherit; font-size: 1.75rem; font-weight: 900; line-height: 1.1; letter-spacing: -0.03em; }
body.layout-b section[data-colour] > h1 { padding: 0.25rem 0.5rem; border: var(--rule); background: var(--group); color: var(--on-colour); }
body.layout-b section[data-colour] > h2 { margin: 1.17rem 0; padding: 0; border: 0; background: none; color: inherit; font-size: 1.17rem; font-weight: 700; line-height: inherit; letter-spacing: 0; }
