/* The look every page of the website shares. The top bar has its own look,
   in shared/top_bar.py. A module's own look is in its own files. */

:root {
  color-scheme: light;
  --ink: #1a1a1a;
  --page: #f2f2f2;
  --focus: #ffcf30; /* the ring around what the keyboard is on */
  --light-line: #b5b2ab;
  --go: #678711; /* a button that goes on, such as Next, and darker under the pointer */
  --go-dark: #4f670d;
}

/* The scrollbar always shows, so that the bar and the page do not shift
   sideways between a page that scrolls and one that does not. */
html { overflow-y: scroll; background: var(--page); }
body { margin: 0; color: var(--ink); font: 16px/1.4 'IBM Plex Sans', sans-serif; }

/* A card, such as a client ref's page, on which a page shows what it is
   about. The space above it narrows from 18px on a wide window to 12px on a
   phone. Where it spans the window, its corners are square and it has no
   border at its sides. A part of the page that reaches the card's corners or
   its sides follows it with --corner, the radius of the card's corners, and
   --side-border, the width of its border at its sides. */
.card { --corner: 9px; --side-border: 1px;
        box-sizing: border-box; max-width: 960px; margin: clamp(12px, 1.2vw + 4.8px, 18px) auto 180px;
        border: solid rgba(0, 0, 0, 0.18); border-width: 1px var(--side-border); border-radius: var(--corner); background: #fff; }
@media (max-width: 960px) {
  .card { --corner: 0px; --side-border: 0px; }
}

/* A client ref's saved addresses, on its page and on the intake's Defendant
   Address: under their heading, a tile for each street, with the street's
   saved units under it. shared/saved_addresses.js lays the tiles out, reading
   the space between tiles and the units' padding and spacing from here. The
   tiles reach 2px past the page's side margins. A street that is a button
   fills its tile when it has no units, and its name goes on to a second line
   if it must. What is inside a tile is rounded at the tile's corners. A page
   gives the tiles its own colors for what it marks and for what is under the
   pointer.

   A saved address can show a few words with it, such as the name from its
   matter's name: above a unit, and after a street. Once any unit has them,
   every unit is as tall as one that does. What follows a street is never
   split, and stays at the right of its first line when the street takes two
   lines. */
.saved { container-type: inline-size; }
.saved h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 20px;
            font-size: 12px; font-weight: 600; line-height: 1.4; letter-spacing: 0.08em; text-transform: uppercase; color: #6f6c66; }
.saved h2::after { content: ""; flex: 1; height: 1px; background: var(--light-line); }
.saved-addresses { display: grid; gap: 38px; margin: 0 -2px; }
.tile { display: flex; flex-direction: column; border: 1px solid var(--light-line); border-radius: 10px; background: #e5dfd1; }
.street { display: flex; align-items: center; box-sizing: border-box; min-height: 44px; padding: 0 15px;
          font-size: 16.5px; font-weight: 500; line-height: 21px; }
button.street { align-items: start; padding: 11.5px 15px; border: 0; border-radius: 9px 9px 0 0; background: none; font-family: inherit; color: inherit;
                text-align: left; cursor: pointer; transition: background-color 0.05s; }
button.street:only-child { flex: 1; border-radius: 9px; }
button.street:has(.who, .count) { align-items: baseline; gap: 12px; }
.units { flex: 1; display: grid; align-content: start; gap: 14px; padding: 15px; border-top: 1px solid var(--light-line); border-radius: 0 0 9px 9px;
         background: #f7f5f3; }
.units button { display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 44px; height: 40px; padding: 0 12px;
                border: 1px solid #bebbb4; border-radius: 6px; background: #fff; font: 15.5px/1 'IBM Plex Sans', sans-serif; color: inherit;
                white-space: nowrap; cursor: pointer; transition: background-color 0.05s, border-color 0.05s; }
.units button:has(.who) { flex-direction: column; gap: 3px; }
.who { font-size: 12.5px; font-weight: 350; line-height: 15px; }
:is(.street .who, .count) { font-size: 14px; font-weight: 350; line-height: normal; white-space: nowrap; }
.saved-addresses:has(.units .who) .units button { height: 52px; }

/* A street that has the focus rings its whole tile. */
.keys .tile:has(> button.street:focus) { outline: 4px solid var(--focus); }
.keys button.street:focus { outline: none; }
/* Where the saved addresses are narrow, as on a phone, the tiles are closer
   together and have less room inside. */
@container (width < 480px) {
  .saved-addresses { gap: 24px; }
  .street { padding: 0 11px; }
  button.street { padding: 11.5px 11px; }
  .units { gap: 10px; padding: 11px; }
  .units button { height: 44px; }
}

/* A pop-up (shared/pop_up.js): its title, what it says, and its buttons at
   the right, the one that goes on last. One that only asks a question is as
   wide as its words. One that explains something is 620px wide where the
   window has room, and its title is brown. A pop-up is never wider than the
   window, less 16px at each side. A button that goes on is green, one that
   goes on another way is blue, and one that discards is red. A button shows
   the focus ring only while the keyboard is in use (top_bar.js). A list
   right under the title has as much room above it as under a paragraph. */
.pop-up { box-sizing: border-box; width: max-content; max-width: min(620px, 100vw - 32px); padding: 24px 28px 22px; border: 0; border-radius: 10px;
          background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25); font-size: 16px; line-height: 23.2px; color: #1d2126; }
.pop-up.wide { width: 620px; }
.pop-up::backdrop { background: rgba(30, 30, 30, 0.35); }
.pop-up:focus { outline: none; }
.pop-up h2 { margin: 0 0 8px; font-size: 19px; font-weight: 600; line-height: 27.5px; }
.pop-up.wide h2 { color: rgba(91, 49, 14, 0.65); }
.pop-up p { margin: 0 0 18px; color: #444; }
.pop-up dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: baseline; gap: 8px 16px; margin: 0 0 22px; }
.pop-up h2 + dl { margin-top: 18px; }
.pop-up dt { font-size: 14px; line-height: 20.3px; color: #666; }
.pop-up dd { margin: 0; font-weight: 500; }
.pop-up .buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.pop-up button { padding: 9px 16px; border: 1px solid #bbb; border-radius: 3px; background: #fff;
                 font: 500 15px/18px 'IBM Plex Sans', sans-serif; color: #333; cursor: pointer; transition: background-color 0.05s, border-color 0.05s; }
.pop-up button:focus { outline: none; }
.keys .pop-up button:focus { outline: 4px solid var(--focus); }
.pop-up .go { border-color: var(--go); background: var(--go); color: #fff; }
.pop-up .go:disabled { opacity: 0.45; cursor: default; }
.pop-up .other { border-color: #3078ab; background: #3078ab; color: #fff; }
.pop-up .discard { border-color: #9f5150; background: #9f5150; color: #fff; }
@media (hover: hover) {
  .pop-up button:hover { border-color: #888; }
  .pop-up .go:not(:disabled):hover { border-color: var(--go-dark); background: var(--go-dark); }
  .pop-up .other:hover { border-color: #28648e; background: #28648e; }
  .pop-up .discard:hover { border-color: #884443; background: #884443; }
}

/* A drop-down (shared/drop_downs.py). The field is on white, inside a gray
   line, with a chevron at its right, and a page gives it its size, to match
   the page's other fields. A choice too long for one line goes on to a
   second, in the field and in the list. The list opens under the field, or
   over it where there is much more room there (shared/drop_downs.js), with
   no gap between them and square corners where they meet, so that it reads
   as the field opened out. The field shows no focus ring while it is open,
   since the choice the keyboard is on shows instead.

   The list is as wide as the field. Each choice is on light tan, with no line
   between choices. The one under the pointer or the keyboard is on gold,
   inside a dark gold line that takes the place of the list's gray edge, with
   no line where it meets a heading, and the one chosen has a check. Opened
   with a click, the list lights only the choice under the pointer. The
   groups' names stand apart from the choices, in small spaced capitals on a
   band of dark brown. When the list is taller than the room it has, it
   scrolls, and a teal bar at its foot says Scroll for more until its end is
   reached. On a narrow screen the choices have more room around them, for a
   finger.

   A drop-down that may be left empty has its blank as the first choice in
   its list, as in No court, in light gray italics, which turn as dark as any
   choice's on gold. The field shows nothing once the blank is chosen.

   A field typed in that suggests what to type, such as Street on Defendant
   Address, lists its suggestions the same way, under the field. The one the
   keyboard or the pointer is on is on gold, marked with the class picked,
   and none has a check, since none is chosen yet. Its page places the list,
   and gives the suggestions the field's size of letters and lines them up
   with the words typed in the field. */
drop-down { display: flex; align-items: center; gap: 10px; box-sizing: border-box; margin: 0; border: 1px solid #bbb; border-radius: 3px;
            background: #fff; font: inherit; color: #000; cursor: pointer; -webkit-user-select: none; user-select: none; }
drop-down:focus { position: relative; z-index: 2; outline: 4px solid var(--focus); }
drop-down[aria-expanded="true"] { anchor-name: --drop-down; border-radius: 3px 3px 0 0; outline: none; }
drop-down.opens-up[aria-expanded="true"] { border-radius: 0 0 3px 3px; }
drop-down .chosen { flex: 1; min-width: 0; }
drop-down::after { content: ""; flex: none; width: 11px; height: 7px; transition: rotate 0.15s;
                   background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' fill='none' stroke='%23333' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat center / contain; }
drop-down[aria-expanded="true"]::after { rotate: 180deg; }
/* The list draws only its top and bottom edges. Each choice draws the list's
   sides beside it, so that the choice on gold can draw them in dark gold. A
   choice the list scrolls to, as the chosen one is when the list opens, stops
   above Scroll for more. */
:is(drop-down [role=listbox], .suggestions) { --edge: #c5c5c5;
                                              box-sizing: border-box; margin: -1px 0 0; padding: 0; overflow: auto; list-style: none;
                                              border: 1px solid var(--edge); border-inline-width: 0; border-radius: 0 0 3px 3px; background: #efe9dc;
                                              box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16); color: #242321; cursor: pointer; }
drop-down [role=listbox] { inset: auto; width: anchor-size(width); max-height: calc(100% - 8px);
                           position-anchor: --drop-down; position-area: block-end span-inline-end; position-try-fallbacks: none; scroll-padding-bottom: 32px; }
:has(> ul.suggestions:not([hidden])) > input { border-radius: 3px 3px 0 0; }
drop-down.opens-up [role=listbox] { margin: 0 0 -1px; border-radius: 3px 3px 0 0; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.16);
                           position-area: block-start span-inline-end; }
drop-down [role=group] { display: block; }
drop-down .group-name { box-sizing: border-box; display: block; padding: 6px 10px; border-inline: 1px solid #6f6557; background: #6f6557;
                     font-size: 12px; font-weight: 600; line-height: 20px; letter-spacing: 0.08em; text-transform: uppercase; color: #fff; cursor: default; }
:is(drop-down [role=option], .suggestions li) { --line-above: #c4b07f; --line-below: #c4b07f;
                                                position: relative; display: block; padding-block: 6px; border-inline: 1px solid var(--edge); background: #efe9dc;
                                                line-height: 25px; transition: background-color 0.05s; }
drop-down [role=option] { padding-inline: 30px 10px; }
drop-down .group-name + [role=option] { --line-above: transparent; }
drop-down :is([role=group]:has(+ [role=group]) > [role=option]:last-child, [role=option]:has(+ [role=group])) { --line-below: transparent; }
drop-down [role=option][aria-selected="true"]::before { content: "\2713"; position: absolute; left: 10px; }
:is(drop-down [role=option].active, .suggestions .picked) { border-color: #c4b07f; box-shadow: inset 0 1px var(--line-above), inset 0 -1px var(--line-below);
                                                            background: #f2d48a; color: #000; }
drop-down .blank { font-style: italic; color: #888; }
/* Scroll for more is a bar of its own over the foot of the list, with a
   shadow above it, so that the choices pass under it. */
drop-down .more { position: sticky; z-index: 2; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 7px; box-sizing: border-box;
                  height: 32px; margin-top: -32px; border-inline: 1px solid #416e7b; background: #416e7b; box-shadow: 0 -6px 10px -4px rgba(0, 0, 0, 0.25);
                  font-size: 14px; font-weight: 600; line-height: 18px; color: #fff; pointer-events: none; opacity: 0; }
drop-down .more::after { content: ""; width: 11px; height: 7px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' fill='none' stroke='%23fff' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat center / contain; }
@media (max-width: 739px) {
  :is(drop-down [role=option], .suggestions li) { padding-block: 9px; line-height: 22px; }
  drop-down [role=option] { padding-inline: 30px 12px; }
}

/* Every page with the bar starts with what is below the bar hidden, and fades
   it in once it is ready. Going to another page, it fades out, with any
   pop-up open and the shade behind it, and so do the line and the shadow
   under the bar (top_bar.py, ARRIVING; top_bar.js). It fades in by an
   animation, not a transition, since a browser can skip a transition on a
   page it has only just drawn, and show the page at once. */
.page-hidden top-bar ~ *, .leaving :is(top-bar ~ *, dialog), .leaving dialog::backdrop { opacity: 0; }
.appearing top-bar ~ * { animation: appear var(--fade); }
.fading :is(top-bar ~ *, dialog), .fading dialog::backdrop { transition: opacity var(--fade); }
@keyframes appear { from { opacity: 0; } }

/* Signing in, the emblem moves from the sign-in page's logo into the bar, and
   logging out, back again. The page puts a copy of it where the page before
   left it, hides its own emblem, and moves the copy to the emblem's place
   (top_bar.js). Signing in, the rest of the bar starts hidden and fades in as
   the emblem moves. Logging out, it fades out first.

   The bar and the sign-in page read these variables. Nothing else of a page's
   style reaches the bar. */
.emblem-moving { --emblem-copy: block; --emblem: hidden; }
.bar-hidden, .leaving-bar { --bar-parts: 0; }
.leaving-bar { --logging-out: #c52a36; }
.leaving { --bar-line: transparent; --bar-shadow: transparent; }
