/* The look of the shopping list. It belongs to this module and not to the toolkit: a note is
   nothing general but the picture of this one thing. What stands here travels along in the package
   of the module and is loaded by the app as soon as it has installed it.

   Colours and spacings come out of the variables of the platform - the note looks different from a
   table, but it looks like the same application. */

/* --- the width: as narrow as a note, as wide as its longest entry ------- */

/* A shopping list is a note and no page. Its standard measure is an A6 sheet in portrait - and it
   grows in BOTH directions: wider when an entry is long, higher when many stand on it. The upper
   limit lies at half the area; above that it would be a page again. */
.note-sheet
{
    width: fit-content;
    /* the width of an A6 sheet, in real centimetres: the browser converts it into pixels, and
       with that the note is as big as one out of the pad - not as big as a font size happens to
       make it. */
    min-width: 10.5cm;
    max-width: min(16cm, 50%);
}

/* on a narrow screen the limit no longer counts - there the note IS the page */
@media (max-width: 720px)
{
    .note-sheet { width: auto; min-width: 0; max-width: 100%; }
}

/* --- entering at the top: shop, article, amount, button ----------------- */

/* --- what was understood: the preview directly under the field --------- */

/* Field and preview belong together and stand one above the other - the information stands where
   one looks while typing anyway, and not at the foot of the note. */
.note-field { display: flex; flex-direction: column; gap: 2px; }

/* It appears only when the parser recognised something - therefore NO reserved place: what is
   not always there does not have to cost space always either. */
.note-guide
{
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--s1);
    padding-left: var(--s2);
    font-size: var(--fs-sm);
}

.note-part { color: var(--text); }

.note-dot { color: var(--text-faint); }

/* a shop that does not exist yet is announced before it comes about */
.note-new { color: var(--link); }

/* --- the note: squared paper that lies on top a little ------------------ */

.note
{
    position: relative;
    list-style: none;
    margin: 0;
    /* Exactly one grid row at the top: with that the first text row begins under the first line,
       and every further one sits on a line again - one writes on the lines, not between them. A
       little more air on the left, the margin of the block runs there. */
    padding: .5cm var(--s3) var(--s3) var(--s4);

    /* The base measure of a note: 10.5 x 13.5 cm. It is a MINIMUM height, no constraint - if more
       rows stand on it, the sheet grows downwards, and a long entry makes it wider. Without this
       value the note would be a strip with one article on it. */
    min-height: 13.5cm;
    box-sizing: border-box;

    /* squared paper: two families of fine lines in the 22px grid. The lines come out of the
       border colour of the platform, so that the sheet fits the rest in every coat of paint - a
       hard set blue would be a hole in the picture on a dark ground. */
    background-color: var(--surface);
    background-image:
        repeating-linear-gradient(to right, var(--border) 0 1px, transparent 1px .5cm),
        repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px .5cm);
    background-position: -1px -1px;

    border: 1px solid var(--border-strong);
    border-radius: 2px;

    /* the sheet lies on top: a fine edge, a soft shadow underneath */
    box-shadow:
        0 1px 1px rgba(16, 24, 40, .06),
        0 6px 14px rgba(16, 24, 40, .10);
}

/* two sheets underneath, slightly offset and turned - that is the whole trick of the "stack":
   they lie BEHIND the sheet and carry nothing but their own edge. */
.note::before,
.note::after
{
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 2px;
}

.note::before { transform: rotate(-.6deg) translate(-3px, 3px); }

.note::after { transform: rotate(.5deg) translate(3px, 5px); }

/* --- the rows ----------------------------------------------------------- */

.note-line
{
    display: flex;
    align-items: center;
    gap: var(--s2);
    /* the height follows the grid, so that the rows sit on the lines */
    min-height: .5cm;
    padding: 0;
}

/* The open row puts field and text ON TOP OF EACH OTHER: the text stays standing invisibly and
   keeps carrying its width - without it the note would shrink the moment one opens its longest
   row, and would grow again on closing. */
.note-line-open
{
    display: grid;
    min-height: 0;
    padding: 1px 0;
}

.note-line-open > * { grid-area: 1 / 1; }

.note-ghost
{
    visibility: hidden;
    white-space: pre;
    /* a little extra, so that the text in the field does not stick to the edge */
    padding-right: var(--s4);
}

.note-line-open .suggest { width: 100%; }

/* under the last row one free grid row always stays: it is the place one clicks to write
   something more - without it a full note would be closed */
.note-space { min-height: 1cm; }

/* the whole row is the click area, aligned left and without the look of a button: it IS the
   entry, it only does not look as if one had to press it */
.note-text
{
    flex: 1 1 auto;
    text-align: left;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    /* a touch bigger than the rest of the surface: a note is read in passing, often with the
       phone in one hand */
    font-size: var(--fs-md);
    /* exactly one grid row high - that way every row sits on its line */
    line-height: .5cm;
}

.note-line:hover .note-text { color: var(--accent); }

/* The bin sits at the right edge and appears under the pointer. Invisible does NOT mean
   unreachable: with the keyboard it becomes visible as soon as it has the focus - a pure hover
   element would never be found by the tab key. */
.note-line > .btn
{
    opacity: 0;
    margin-left: auto;
    transition: opacity .12s ease-in-out;
}

.note-line:hover > .btn,
.note-line > .btn:focus-visible { opacity: 1; }

/* where there is no pointer, the bin always stands there */
@media (hover: none)
{
    .note-line > .btn { opacity: 1; }
}

/* --- dragging a row to its new place ------------------------------------ */

/* while a row travels, nothing shall be selected under it */
.note-dragging { user-select: none; }

/* the dragged row lifts off the sheet a little and travels over the others */
.note-dragged
{
    position: relative;
    z-index: 1;
    opacity: .85;
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(16, 24, 40, .18);
}

.note-dragged .note-text { cursor: grabbing; }

/* the rows that step aside for the dragged one slide, they do not jump - the dragged row itself
   follows the pointer without a delay */
.note-dragging .note-line:not(.note-dragged) { transition: transform .12s ease-out; }

/* --- the scanner pages (2026-09-17): steps to read, and a book of codes --------------- */

/* the heading of the scanner section with the way to the book of codes beside it */
.scan-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }

.scan-head h3 { margin: 0; }

/* The setup is a numbered list of steps, each with its code. The numbers stand in the headings
   themselves, so the list keeps no markers of its own. */
.scan-steps
{
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s3);
}

.scan-step
{
    padding: var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.scan-step h4 { margin: 0 0 var(--s1); }

.scan-step p { margin: 0 0 var(--s2); }

/* A code stands on white with a rim of white around it, whatever the page looks like: a scanner
   needs the quiet zone, and it reads the screen, not the theme. */
.scan-code
{
    display: inline-block;
    padding: var(--s2);
    background: #fff;
    border-radius: var(--radius-sm);
    max-width: 100%;
    overflow-x: auto;
}

.scan-code svg { display: block; max-width: 100%; height: auto; }

/* what stands in a step instead of a code: the network is not configured, the key is gone */
.scan-missing { color: var(--text-muted); font-size: var(--fs-sm); }

/* a value to type over (2026-09-21): one line, the whole width, easy to mark */
.scan-text
{
    margin: var(--s3) 0;
    padding: var(--s2) var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-family: var(--mono);
    font-size: var(--fs-md);
    overflow-x: auto;
    user-select: all;
}

/* the trial reported: the scanner has been heard from */
.scan-seen { color: var(--ok-fg); font-weight: 600; }

/* The book of codes: only NAMES on the page, in columns - a code is drawn alone in its dialog,
   never beside another one a scanner could catch by mistake (2026-09-18). */
.scan-names
{
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 3 220px;
    column-gap: var(--s4);
}

.scan-names li { break-inside: avoid; }

.scan-name
{
    display: block;
    width: 100%;
    padding: var(--s1) 0;
    border: 0;
    background: none;
    color: var(--link);
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.scan-name:hover { text-decoration: underline; }

.scan-name:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }

/* --- one step at a time (2026-09-18) ------------------------------------------------------ */

/* the steps inside the dialog - the dialog itself takes the keyboard: the arrows walk the steps */
.scan-wizard { display: flex; flex-direction: column; gap: var(--s2); }

.scan-wizard h3 { margin: 0; }

.scan-wizard p { margin: 0; }

.scan-label { font-weight: 600; }

/* a code alone in the dialog of the book: in the middle, with white around it */
.scan-code-alone { display: block; width: fit-content; margin: 0 auto; }

/* the trial passed: a thick green check mark beside the words */
.scan-ok
{
    display: flex;
    align-items: center;
    gap: var(--s2);
    color: var(--ok-fg);
    font-weight: 700;
    font-size: var(--fs-md);
}

.scan-check { display: inline-flex; }

.scan-check svg { width: 40px; height: 40px; stroke-width: 3; }


/* --- the hand moves of a step (2026-09-18): a numbered list, do and show on one line ----- */

.scan-acts
{
    margin: 0;
    padding-left: 1.4em;
    display: flex;
    flex-direction: column;
    gap: var(--s1);
}

.scan-acts li { padding-left: var(--s1); }

.scan-do { font-weight: 600; }

.scan-arrow { color: var(--text-faint); padding: 0 var(--s1); }

.scan-show { color: var(--text-muted); }

/* what to do when the device does not show it - under the list, in the colour of a warning */
.scan-fail { color: var(--err-fg); font-size: var(--fs-sm); }

/* TEXT HANGS OVER THE PAGE (2026-09-20): a link or a recipe text on its way - the sheet says it
   takes it. Files get the toolkit's box; this is the island's own mark. */
.note-drop-over { outline: 2px dashed var(--accent); outline-offset: 4px; }

/* the settings of a reading module (2026-09-22): short inputs, the words of the lights as they are */
.reader-table input[type="number"] { width: 6em; }
.reader-table input.reader-outside { border-color: var(--err-fg); outline: 1px solid var(--err-fg); }
.reader-table td, .reader-table th { vertical-align: middle; }

/* the console of the board on the port (2026-09-22): a few lines, the newest at the bottom */
.scan-console
{
    margin: var(--s3) 0 0;
    padding: var(--s2) var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    font-family: var(--mono);
    font-size: var(--fs-sm);
    white-space: pre-wrap;
    overflow-x: auto;
}

/* the wiring picture of the self-built scanner (2026-09-22): as wide as the dialog, never wider */
.scan-wiring { display: block; width: 100%; max-width: 560px; height: auto; margin: var(--s3) auto; }
