/* An entity's stamp, drawn as a passport stamp (founder, 2026-11-26; acctg/stamps.py, templates/_stamp.html).
   Passport only: the one block below opens for the Passport page and a Passport preview, and steps aside inside
   another theme's preview. Ledger and NoVentanas never see it; there a stamp keeps its plain look and the parts
   added for this one stay hidden (app.css).

   A stamp is a box of real words: the name, the small line (tag, place, currency, a closing note) and, where a
   formation date is on record, the date. They are never worn. Everything else is the last element, `.wr`: the frame
   and its decoration, behind the words. Only `.wr` carries the wear: a filter for the specks (`_stamp_defs.html`) and
   a mask for the fainter side or the corner that did not print. The style, tilt, wear and the date's ink are data
   attributes the page sets from the entity's stored look. The header's control is the same stamp, smaller and nearly
   straight. No script. */

.stamp-defs { position: absolute; }
/* What a stamp is stamped on: a card, unless it is in the header's list or is the header's control. The banner style
   cuts its stars out of its band in this color and backs its number with it. */
.stamp[data-stamp] { --stamp-surface: var(--card); }
ul.pick-list .stamp[data-stamp] { --stamp-surface: var(--menu); }
details.entity-pick > summary[data-stamp] { --stamp-surface: var(--cover); }

:is(html:not([data-theme]), .look-passport) :is(.stamp, details.entity-pick > summary)[data-stamp]:not(.look:not(.look-passport) *) {
  --stamp-tilt: 0deg;
  position: relative; isolation: isolate; display: inline-block; vertical-align: middle; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  border: 0; outline: 0; border-radius: 0; background: none; padding: 9px 16px 8px;
  font-family: var(--sans); font-weight: 700; font-size: var(--text-xs); line-height: 1.25; letter-spacing: var(--tracking-caps);
  text-align: center; text-transform: uppercase; white-space: nowrap; transform: rotate(var(--stamp-tilt));

  &:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
  /* Chosen, and pointed at (founder, 2026-11-26): the same for every style and ink, on every page. A background means
     chosen and nothing else: the chosen stamp's own shape fills with the highlight color a chosen row has
     (`--stamp-fill`, painted inside each style's outline below), and its ink is printed whole. A stamp pointed at or
     focused gets no background: its ink is printed whole and it sits level for as long as the pointer is on it.
     Never a second frame around a stamp: a box reads as part of the design. */
  --stamp-fill: transparent; transition: transform var(--dur-1) var(--ease);
  &.picked { --stamp-fill: var(--notice); box-shadow: none; }
  &:is([data-stamp="boxes"], [data-stamp="banner"], [data-stamp="form"]) .wr::before, & .sides, &[data-stamp="ticket"] .wr { background-color: var(--stamp-fill); }
  & svg.shape > :first-child { fill: var(--stamp-fill); }
  &[data-tilt="1"] { --stamp-tilt: -2.6deg; } &[data-tilt="2"] { --stamp-tilt: 1.9deg; } &[data-tilt="3"] { --stamp-tilt: -1.1deg; }
  &[data-tilt="4"] { --stamp-tilt: 2.7deg; } &[data-tilt="5"] { --stamp-tilt: -3.2deg; }
  &[data-size="list"] { transform: rotate(calc(var(--stamp-tilt) * .4)); }
  /* In the header: about one degree, either way. */
  &[data-size="head"]:is([data-tilt="1"], [data-tilt="3"], [data-tilt="5"]) { --stamp-tilt: -1deg; }
  &[data-size="head"]:is([data-tilt="2"], [data-tilt="4"]) { --stamp-tilt: 1deg; }
  &[data-stamp]:is(a, summary):is(:hover, :focus-visible), details.entity-pick[open] > &[data-stamp] { --stamp-tilt: 0deg; }   /* pointed at: level */

  /* The words. */
  & :is(.fig, .pick-fig) { display: block; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-weight: 400; font-size: var(--text-2xs);
                           line-height: 1.3; letter-spacing: .01em; text-transform: none; margin-top: 2px; }
  & .dt { display: block; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-weight: 600; font-size: var(--text-2xs); line-height: 1.3; letter-spacing: .04em; margin-top: 1px; }
  &[data-date-ink="navy"] .dt { color: var(--navy); } &[data-date-ink="red"] .dt { color: var(--red); }
  &[data-date-ink="green"] .dt { color: var(--green); } &[data-date-ink="amber"] .dt { color: var(--amber); }
  &.closed .dt { color: inherit; }
  /* An entry arrow before the small line; an exit arrow once the entity is closed. Our own marks, as masks. */
  &:not([data-stamp="boxes"]) :is(.fig, .pick-fig)::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: -1px;
      background: currentColor; mask: url("stamp-in.svg") center / contain no-repeat; }
  &:not([data-stamp="boxes"]):is(.closed, [data-closed]) :is(.fig, .pick-fig)::before { mask-image: url("stamp-out.svg"); }

  /* The worn layer: the frame and the decoration, behind the words. */
  & .wr { display: block; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
  & .wr i, & .dt i { font-style: normal; }
  &[data-wear="1"] .wr { filter: url(#stamp-wear-1); mask-image: linear-gradient(100deg, var(--shade) 52%, color-mix(in srgb, var(--shade) 62%, transparent)); }
  &[data-wear="2"] .wr { filter: url(#stamp-wear-2); mask-image: linear-gradient(262deg, var(--shade) 46%, color-mix(in srgb, var(--shade) 60%, transparent)); }
  &[data-wear="3"] .wr { filter: url(#stamp-wear-3); mask-image: radial-gradient(circle at 97% 6%, transparent 0 10%, var(--shade) 30%); }
  &[data-wear="4"] .wr { filter: url(#stamp-wear-1); mask-image: linear-gradient(8deg, color-mix(in srgb, var(--shade) 58%, transparent), var(--shade) 50%); }
  /* The chosen one, and one pointed at, are printed whole. */
  &.picked .wr, &[data-stamp]:is(a, summary):is(:hover, :focus-visible) .wr, details.entity-pick[open] > & .wr { filter: none; mask-image: none; }
  & .ar { width: 11px; height: 11px; }
  & svg.shape { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; overflow: visible; }
  & svg.shape * { vector-effect: non-scaling-stroke; }
  & svg.shape .thin { stroke-width: 1; opacity: .8; }
  & svg.shape .dots { stroke-width: 1.7; stroke-dasharray: .1 3.4; stroke-linecap: round; opacity: .9; }
  & svg.shape .ticks { stroke-width: 4.4; stroke-dasharray: 1.2 2.4 3.2 2.4; opacity: .9; }
  /* A closed entity: quiet ink (its color class says so) and every line dashed. */
  &:is(.closed, [data-closed]) :is(.bx, .sides, .col, .no, .hd, .edge, .mt), &:is(.closed, [data-closed]) .wr::before,
  &:is(.closed, [data-closed]) .wr::after, &:is(.closed, [data-closed]) .top::before, &:is(.closed, [data-closed]) .top::after { border-style: dashed; }
  &:is(.closed, [data-closed]) svg.shape * { stroke-dasharray: 5 3; }

  /* 1 Boxes: a rounded frame, an arrow box over a plane box, a ring of stars. */
  &[data-stamp="boxes"] { padding: 9px 46px 8px 46px; }
  &[data-stamp="boxes"] .wr::before { content: ""; position: absolute; inset: 0; border: 1.7px solid; border-radius: var(--radius-lg);
                                      box-shadow: 1.3px 1px 0 color-mix(in srgb, currentColor 30%, transparent); }
  &[data-stamp="boxes"] .wr::after { content: ""; position: absolute; inset: 3.5px; border: 1px solid; border-radius: var(--radius); opacity: .75; }
  & .bx { position: absolute; left: 8.5px; top: 8.5px; bottom: 8.5px; width: 28px; border: 1.3px solid; border-radius: var(--radius-sm);
          display: grid; grid-template-rows: 1fr 1fr; place-items: center; }
  & .bx::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1.3px solid; }
  & .bx .ar { width: 15px; height: 15px; }
  & .ring { position: absolute; right: 9px; top: 50%; translate: 0 -50%; width: 31px; height: 31px; }
  & .ring text { font-family: var(--mono); font-weight: 600; font-size: var(--text-3xs); letter-spacing: 0; fill: currentColor; }

  /* 2 Broken frame: the top line of words runs through the border; digits down one side. */
  &[data-stamp="broken"] { padding: 15px 32px 9px 15px; }
  & .top:not(.mt) { position: absolute; left: 0; right: 0; top: 0; height: 12px; display: flex; align-items: center; gap: 7px;
           font-family: var(--mono); font-weight: 600; font-size: var(--text-3xs); line-height: 1; letter-spacing: .16em; }
  & .top:not(.mt)::before { content: ""; flex: 0 0 16px; border-top: 2.2px solid; } & .top:not(.mt)::after { content: ""; flex: 1; border-top: 2.2px solid; }
  & .sides { position: absolute; inset: 5px 0 0 0; border: 2.2px solid; border-top: 0; box-shadow: 1.2px 1px 0 color-mix(in srgb, currentColor 28%, transparent); }
  & .col { position: absolute; right: 6px; top: 13px; bottom: 6px; width: 15px; border-left: 1.2px solid; writing-mode: vertical-rl;
           font-family: var(--mono); font-weight: 600; font-size: var(--text-3xs); line-height: 15px; letter-spacing: .1em; overflow: hidden; }

  /* 3 Oval: two rings. 4 Wave: the whole stamp waves like a flag. 6 Cut oval: curved above and below, a band of ticks. */
  &[data-stamp="oval"] { padding: 22px 42px 20px; }
  &[data-stamp="wave"] { padding: 24px 26px 24px; }
  &[data-stamp="cutoval"] { padding: 21px 30px 23px; }

  /* 5 Ticket: cut corners; the edge is the code in tiny repeated letters. */
  &[data-stamp="ticket"] { padding: 14px 20px 12px; }
  &[data-stamp="ticket"] .wr { clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px); }
  &[data-stamp="ticket"] .wr::after { content: ""; position: absolute; inset: 9.5px; border: 1px solid; opacity: .7; }
  & .mt { position: absolute; font-family: var(--mono); font-weight: 600; font-size: var(--text-4xs); line-height: 7.5px; letter-spacing: .05em; white-space: nowrap; overflow: hidden; }
  & .mt.top { left: 0; right: 0; top: 0; height: 8px; border-bottom: 1px solid; } & .mt.bot { left: 0; right: 0; bottom: 0; height: 8px; border-top: 1px solid; }
  & .mt.lf { left: 0; top: 8px; bottom: 8px; width: 8px; writing-mode: vertical-rl; border-right: 1px solid; }
  & .mt.rt { right: 0; top: 8px; bottom: 8px; width: 8px; writing-mode: vertical-rl; border-left: 1px solid; }

  /* 7 Banner: a solid band of stars, a number in a circle, wavy lines. */
  &[data-stamp="banner"] { padding: 20px 50px 9px 14px; text-align: left; }
  &[data-stamp="banner"] .wr::before { content: ""; position: absolute; inset: 0; border: 1.7px solid; border-top: 0; box-shadow: 1.2px 1px 0 color-mix(in srgb, currentColor 28%, transparent); }
  & .bn { position: absolute; left: 0; right: 0; top: 0; height: 14px; background: currentColor; display: flex; align-items: center; gap: 6px; padding-left: 9px; }
  & .bn svg { width: 8.5px; height: 8.5px; color: var(--stamp-surface); }
  & .no { position: absolute; right: 9px; top: 5px; width: 27px; height: 27px; border-radius: 50%; border: 1.6px solid;
          background: linear-gradient(var(--stamp-fill), var(--stamp-fill)), var(--stamp-surface);
          font-family: var(--mono); font-weight: 600; font-size: var(--text-3xs); line-height: 24px; letter-spacing: 0; text-align: center; }
  & .wv { position: absolute; right: 7px; bottom: 6px; width: 34px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.2; }

  /* 8 Form: a header row, the name, a rule, the small line; digits down the right edge. */
  &[data-stamp="form"] { padding: 19px 28px 7px 12px; }
  &[data-stamp="form"] .wr::before { content: ""; position: absolute; inset: 0; border: 1.7px solid; box-shadow: 1.2px 1px 0 color-mix(in srgb, currentColor 28%, transparent); }
  & .hd { position: absolute; left: 0; right: 16px; top: 0; height: 13px; border-bottom: 1.2px solid; text-align: center;
          font-family: var(--mono); font-weight: 600; font-size: var(--text-3xs); line-height: 13px; letter-spacing: .22em; }
  & .edge { position: absolute; right: 0; top: 0; bottom: 0; width: 16px; border-left: 1.2px solid; writing-mode: vertical-rl;
            font-family: var(--mono); font-weight: 600; font-size: var(--text-3xs); line-height: 16px; letter-spacing: .12em; overflow: hidden; white-space: nowrap; }
  &[data-stamp="form"] :is(.fig, .pick-fig) { border-top: 1px solid color-mix(in srgb, currentColor 70%, transparent); margin-top: 4px; padding-top: 3px; }

  /* In the header's list: one to a row, straighter, no date. */
  &[data-size="list"] .dt { display: none; }
  &[data-size="list"][data-stamp="boxes"] { padding: 7px 44px 6px 44px; } &[data-size="list"][data-stamp="broken"] { padding: 13px 30px 7px 13px; }
  &[data-size="list"][data-stamp="oval"] { padding: 15px 34px 14px; } &[data-size="list"][data-stamp="wave"] { padding: 18px 22px 18px; }
  &[data-size="list"][data-stamp="ticket"] { padding: 12px 18px 10px; } &[data-size="list"][data-stamp="cutoval"] { padding: 17px 28px 19px; }
  &[data-size="list"][data-stamp="banner"] { padding: 18px 40px 7px 12px; } &[data-size="list"][data-stamp="banner"] .wv { display: none; }
  &[data-size="list"][data-stamp="form"] { padding: 17px 26px 6px 10px; }

  /* The header's control: the same stamp, made simpler, no taller than the header allows. */
  &[data-size="head"] { max-width: none; overflow: visible; }
  &[data-size="head"] .dt, &[data-size="head"] .swatch, &[data-size="head"] .pick-code { display: none; }
  &[data-size="head"] .pick-name { display: block; max-width: 11em; overflow: hidden; text-overflow: ellipsis; }
  /* Its small line: where it answers to, then its date, or its full name where it goes by a shorter one. A long name
     is cut here, where it is the lesser line. */
  &[data-size="head"] .pick-fig { margin-top: 0; max-width: 24ch; }
  &[data-size="head"]::after { right: -15px; color: var(--cover-ink); }
  &[data-size="head"][data-stamp="boxes"] { padding: 5px 12px 4px 34px; }
  &[data-size="head"][data-stamp="boxes"] :is(.ring, .pl), &[data-size="head"][data-stamp="boxes"] .bx::after { display: none; }
  &[data-size="head"][data-stamp="boxes"] .bx { left: 6px; top: 6px; bottom: 6px; width: 21px; grid-template-rows: 1fr; }
  &[data-size="head"][data-stamp="boxes"] .wr::before { border-radius: var(--radius); } &[data-size="head"][data-stamp="boxes"] .wr::after { border-radius: var(--radius-sm); }
  &[data-size="head"][data-stamp="broken"] { padding: 9px 24px 4px 10px; }
  &[data-size="head"][data-stamp="broken"] .top { height: 9px; } &[data-size="head"][data-stamp="broken"] .top b { display: none; }
  &[data-size="head"][data-stamp="broken"] .top::before { flex: 0 0 30%; } &[data-size="head"][data-stamp="broken"] .top::after { margin-left: 22px; }
  &[data-size="head"][data-stamp="broken"] .sides { inset: 3.5px 0 0 0; border-width: 1.8px; }
  &[data-size="head"][data-stamp="broken"] .col { right: 4px; top: 9px; bottom: 4px; width: 12px; line-height: 12px; }
  &[data-size="head"][data-stamp="oval"] { padding: 6px 28px 6px; }
  &[data-size="head"][data-stamp="wave"] { padding: 9px 18px 8px; } &[data-size="head"][data-stamp="wave"] svg.shape .thin { display: none; }
  &[data-size="head"][data-stamp="ticket"] { padding: 9px 13px 8px; }
  &[data-size="head"][data-stamp="ticket"] :is(.mt.lf, .mt.rt), &[data-size="head"][data-stamp="ticket"] .wr::after { display: none; }
  &[data-size="head"][data-stamp="ticket"] .mt:is(.top, .bot) { height: 7px; line-height: 6.5px; }
  &[data-size="head"][data-stamp="ticket"] .wr { clip-path: polygon(7px 0, calc(100% - 7px) 0, 100% 7px, 100% calc(100% - 7px), calc(100% - 7px) 100%, 7px 100%, 0 calc(100% - 7px), 0 7px); }
  &[data-size="head"][data-stamp="ticket"] .wr::before { content: ""; position: absolute; inset: 0; border-left: 1.2px solid; border-right: 1.2px solid; }
  &[data-size="head"][data-stamp="cutoval"] { padding: 8px 22px 9px; }
  &[data-size="head"][data-stamp="cutoval"] svg.shape .ticks { stroke-width: 2.4; stroke-dasharray: 1 2 2.4 2; } &[data-size="head"][data-stamp="cutoval"] svg.shape .thin { display: none; }
  &[data-size="head"][data-stamp="banner"] { padding: 10px 34px 2px 10px; }
  &[data-size="head"][data-stamp="banner"] .bn { height: 8px; gap: 4px; padding-left: 6px; } &[data-size="head"][data-stamp="banner"] .bn svg { width: 5.5px; height: 5.5px; }
  &[data-size="head"][data-stamp="banner"] .no { right: 6px; top: 3px; width: 22px; height: 22px; line-height: 19px; } &[data-size="head"][data-stamp="banner"] .wv { display: none; }
  &[data-size="head"][data-stamp="form"] { padding: 5px 24px 4px 10px; }
  &[data-size="head"][data-stamp="form"] .hd { display: none; } &[data-size="head"][data-stamp="form"] .edge { width: 14px; line-height: 14px; }
  &[data-size="head"][data-stamp="form"] .pick-fig { border-top: 0; margin-top: 0; padding-top: 0; }
}

/* In the header's list each stamp keeps its own width and stands in the middle of its row. */
:is(html:not([data-theme]), .look-passport) ul.pick-list.stamped > li:not(.pick-all):not(.look:not(.look-passport) *) { text-align: center; }
/* Room beside the control for its arrow, which stands outside the stamp. */
:is(html:not([data-theme]), .look-passport) details.entity-pick:has(> summary[data-stamp]):not(.look:not(.look-passport) *) { margin-right: 14px; }
/* On the map a long name may wrap, so a stamp never pushes its neighbors off the page. */
:is(html:not([data-theme]), .look-passport) .org .stamp[data-stamp]:not(.look:not(.look-passport) *) { white-space: normal; max-width: 230px; }
