/* ─────────────────────────────────────────────────────────────
   Cotrugli — Components
   Token-driven, framework-free recreations of the kit primitives.
   Each block maps 1:1 to a component in the design bundle's
   primitives.jsx, so it can become a Phoenix function component later.
   ───────────────────────────────────────────────────────────── */

/* ── Icon — Tabler outline, inherits color, 1.5 stroke (see sprite) ── */
.icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.icon--12 { width: 12px; height: 12px; }
.icon--14 { width: 14px; height: 14px; }
.icon--16 { width: 16px; height: 16px; }
.icon--20 { width: 20px; height: 20px; }
.icon--24 { width: 24px; height: 24px; }
.icon--32 { width: 32px; height: 32px; }

/* ── Mark — outlined square + signal "C" ── */
.mark {
  --mk-size: 28px; --mk-font: 15px; --mk-border: 1px;
  width: var(--mk-size); height: var(--mk-size);
  border: var(--mk-border) solid var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: var(--mk-font); font-weight: 500;
  color: var(--signal); line-height: 1; flex-shrink: 0;
}
.mark--26 { --mk-size: 26px; --mk-font: 14px; --mk-border: 1px; }
.mark--36 { --mk-size: 36px; --mk-font: 20px; --mk-border: 1.2px; }

/* ── Wordmark — "Cotrugli" with the custom signal-dot i (em-scaled) ── */
.wordmark {
  font-family: var(--font-sans); font-weight: 500; font-size: 18px;
  letter-spacing: -0.025em; color: var(--text); line-height: 1;
  display: inline-flex; align-items: baseline;
}
.wordmark__i { position: relative; display: inline-block; width: 0.26em; height: 0.73em; margin-left: 0.015em; }
.wordmark__stem { position: absolute; bottom: 0; left: 50%; width: 0.11em; height: 0.516em; background: currentColor; transform: translateX(-50%); }
.wordmark__dot  { position: absolute; top: 0;    left: 50%; width: 0.11em; height: 0.11em;  background: var(--signal); transform: translateX(-50%); }

/* ── Animated mark — the deck cover's draw-on, threshold surfaces only
   (login, gate). Console chrome arrives settled; this is the one sanctioned
   arrival choreography, at the door. ── */
.mark-draw { color: var(--text); display: inline-block; }
.mark-draw__box { stroke-dasharray: 1; stroke-dashoffset: 1; animation: mark-draw 620ms var(--ease-out) 120ms forwards; }
.mark-draw__c { font-family: var(--font-mono); font-size: 30px; font-weight: 500; fill: var(--signal); opacity: 0; animation: mark-fade 320ms var(--easing) 580ms forwards; }
@keyframes mark-draw { to { stroke-dashoffset: 0; } }
@keyframes mark-fade { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .mark-draw__box { stroke-dashoffset: 0; }
  .mark-draw__c { opacity: 1; }
}

/* ── Auth threshold — the sign-in page's centered column ── */
.auth-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; text-align: center; }
.auth-shell__brand { display: flex; flex-direction: column; align-items: center; gap: 16px; text-decoration: none; color: var(--text); }
.auth-shell__sub { margin-top: 12px; }

/* ── Lockup — mark + wordmark (chrome; never underlined) ── */
.lockup { display: inline-flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); }

/* ── Button — five flavors, tokenized. Hovers LIGHTEN (one step, never a
   dim); press is a transform on the base transition so it lands instantly
   and eases on release. ── */
.btn {
  font-family: var(--font-sans); font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--r-2); border: 1px solid transparent;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background-color var(--t-base) var(--easing),
              border-color var(--t-base) var(--easing),
              color var(--t-base) var(--easing),
              transform var(--t-quick) var(--ease-out);
}
.btn--lg { font-size: 14px; padding: 10px 18px; }   /* marketing scale */

.btn--primary   { background: var(--text); color: var(--surface); }
.btn--primary:hover   { background: var(--text-hover); }
.btn--secondary { background: transparent; border-color: var(--surface-rule); color: var(--text); }
.btn--secondary:hover { border-color: var(--text-subtle); background: var(--surface-hover); }
.btn--ghost     { background: transparent; border-color: var(--surface-rule); color: var(--text-muted); }
.btn--ghost:hover     { border-color: var(--text-subtle); background: var(--surface-hover); color: var(--text); }
.btn--danger    { background: transparent; border-color: var(--danger); color: var(--danger); }
/* color-mix keeps the danger wash honest on any surface it sits on. */
.btn--danger:hover    { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn--agent     { background: var(--signal); color: var(--signal-ink); font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.02em; }
.btn--agent:hover     { background: var(--signal-soft); }

/* Pressed: every button answers the finger, instantly. The same press extends
   to the segmented, tab, and pill controls (their transforms ease back on
   release; see each control's transition). Wide list rows are left out - a
   scale on a full-width row reads as a wobble, not a press. */
.btn:active, .icon-btn:active,
.desk-tab:active, .switcher__btn:active, .tenant-option:active,
.tb__ctl:active, .approvals-new-pill:active { transform: translateY(0.5px) scale(0.98); }
@media (prefers-reduced-motion: reduce) {
  .btn:active, .icon-btn:active,
  .desk-tab:active, .switcher__btn:active, .tenant-option:active,
  .tb__ctl:active, .approvals-new-pill:active { transform: none; }
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* Colored flavors also drain: opacity alone still reads clickable. */
.btn--primary:disabled, .btn--danger:disabled, .btn--agent:disabled { filter: saturate(0); }
/* In-flight (phx-click-loading): the label steps back but keeps its width —
   the button never jumps layout while the round-trip runs. */
.btn--secondary.phx-click-loading, .btn--ghost.phx-click-loading, .btn--danger.phx-click-loading { color: var(--text-muted); }
.btn--primary.phx-click-loading, .btn--agent.phx-click-loading { opacity: 0.75; }

/* ── Arrow link — one vocabulary for "this navigates somewhere" ──
   Composes onto an existing link class; the arrow nudges 2px on hover
   (a state change on the system's quick token, stilled under
   prefers-reduced-motion). */
.arrow-link { display: inline-flex; align-items: center; gap: 6px; }
.arrow-link .icon { flex: none; transition: transform var(--t-quick) var(--ease-out); }
.arrow-link:hover .icon { transform: translateX(2px); }
@media (prefers-reduced-motion: reduce) {
  .arrow-link:hover .icon { transform: none; }
}

/* ── Badge — agent + four states + neutral ── */
.badge {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tr-wide);
  padding: 3px 7px; border-radius: var(--r-1); display: inline-flex;
  align-items: center; gap: 6px; text-transform: uppercase; line-height: 1.4;
  border: 1px solid transparent;
}
.badge__dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
/* A severity badge may lead with a glyph instead of the dot: shape as well as
   colour, so the tier reads without relying on colour alone. The glyph takes
   the badge's own colour (currentColor). */
.badge--icon { gap: 5px; }
.badge__icon { width: 12px; height: 12px; flex: none; margin: -1px 0; }
.badge--agent   { background: var(--signal); color: var(--signal-ink); }
.badge--agent .badge__dot { background: var(--signal-ink); }
.badge--success { background: var(--surface-elev); color: var(--success); border-color: var(--surface-rule); }
.badge--warning { background: var(--surface-elev); color: var(--warning); border-color: var(--surface-rule); }
.badge--danger  { background: var(--surface-elev); color: var(--danger);  border-color: var(--surface-rule); }
.badge--info    { background: var(--surface-elev); color: var(--info);    border-color: var(--surface-rule); }
.badge--neutral { background: var(--surface);      color: var(--text-muted); border-color: var(--surface-rule); }

/* ── Pill — marketing tag (signal outline / neutral outline) ── */
.pill {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tr-label);
  padding: 3px 8px; border-radius: var(--r-1); text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.4;
  border: 1px solid transparent;
}
.pill--signal  { color: var(--signal); border-color: var(--signal); }
.pill--neutral { color: var(--text-subtle); border-color: var(--surface-rule); }

/* ── Section tag — "§ 01: label", mono, neutral text with a signal kicker
   tick (marketing exception: a tick, never a painted label). ── */
.section-tag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tr-label);
  color: var(--text-subtle); text-transform: uppercase; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.section-tag::before {
  content: ""; width: 6px; height: 6px; background: var(--signal); flex-shrink: 0;
}

/* ── Stat — big mono number + label (tiles) ── */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tr-label); text-transform: uppercase; color: var(--text-subtle); }
.stat__value { font-family: var(--font-mono); font-size: 26px; font-weight: 500; color: var(--text); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat__sub   { font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }

/* ── Cards — borders, not boxes. No shadows, anywhere. ── */
.card          { background: var(--surface-elev); border: 1px solid var(--surface-rule); border-radius: var(--r-3); }
.card--elevated{ background: var(--surface); border: 1px solid var(--text-faint); }
.card--accent  { border-left: 2px solid var(--signal); border-radius: 0 var(--r-3) var(--r-3) 0; }  /* agent content only */

/* ── Data table — the signature surface ──
   Separate borders, not collapsed: a collapsed border belongs to the grid,
   so it scrolls out from under a sticky header. Every rule in the table is
   a border-bottom on its own cell (never a top), so nothing doubles. */
.data-table { width: 100%; font-size: 13px; border-collapse: separate; border-spacing: 0; }
.data-table th {
  text-align: left; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: var(--tr-label); color: var(--text-subtle); text-transform: uppercase;
  padding: 10px 14px; border-bottom: 1px solid var(--surface-rule); font-weight: 500;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--surface-rule); color: var(--text); vertical-align: middle; }
/* Edge cells take the panel gutter, so the first column's left edge lands
   exactly under the panel head's text (14px inter-column rhythm stays). */
.data-table th:first-child, .data-table td:first-child { padding-left: var(--pad-panel); }
.data-table th:last-child, .data-table td:last-child { padding-right: var(--pad-panel); }
.data-table--flush tbody tr:last-child td { border-bottom: none; }   /* BAS / numbers tables drop the final rule */
.data-table .num   { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.data-table .mono  { font-family: var(--font-mono); }
.data-table .muted { color: var(--text-muted); }
.col-right { text-align: right; }

/* Reconciliation row hover — a quiet lift, no color. Hovers LIGHTEN,
   never recess: a darker row reads as a hole in the panel. */
.data-table--rows tbody tr { transition: background-color var(--t-quick) var(--easing); }
.data-table--rows tbody tr:hover { background: var(--surface-hover); }

/* ── Match cell (reconcile) — badge + mono confidence ── */
.match { display: inline-flex; align-items: center; gap: 8px; }
.match__conf { color: var(--text-subtle); font-family: var(--font-mono); font-size: 11px; }

/* ── Confidence bar (exceptions) ── */
.confbar { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.confbar__track { flex: 1; height: 4px; background: var(--surface-rule); border-radius: 1px; overflow: hidden; }
.confbar__fill  { height: 100%; transition: width var(--t-base) var(--ease-out), background-color var(--t-base) var(--easing); }
.confbar__fill--high { background: var(--signal); }
.confbar__fill--mid  { background: var(--warning); }
.confbar__fill--low  { background: var(--danger); }
.confbar__pct { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }

/* ── Tooltip — [data-tip] ──
   Floating chrome, so the overlay physics apply (surface step + hairline +
   the one sanctioned shadow). Fade only (linear), delayed on the way in so
   passing the pointer across chrome never flashes copy. The host keeps its
   own aria-label/text; the tip is the visual layer. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  z-index: var(--z-tip);
  width: max-content; max-width: 240px; white-space: normal;
  background: var(--surface-overlay); border: 1px solid var(--surface-rule);
  border-radius: var(--r-2); box-shadow: var(--shadow-overlay);
  padding: 6px 10px;
  font: 400 11px/1.45 var(--font-sans); letter-spacing: normal;
  text-transform: none; text-align: left; color: var(--text);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-quick) var(--easing);
}
[data-tip]:hover::after { opacity: 1; transition-delay: 300ms; }
[data-tip]:focus-visible::after { opacity: 1; }
/* Placement, space-separated in data-tip-pos: hosts at the top of a clipping
   container (topbar, panel heads) drop the tip below; hosts against a right
   edge pin it to their right end so it grows into open space, not the clip. */
[data-tip-pos~="down"]::after { bottom: auto; top: calc(100% + 6px); }
[data-tip-pos~="end"]::after { left: auto; right: 0; transform: none; }

/* ── Keycap — .kbd ──
   The machined key: a top-lit cap seated in a dark well. This gradient is
   the ONE sanctioned gradient beyond chart fills — the keycap: a physical
   object, not a surface (keyboard hardware, carved out the way the
   chart-fill fade is). Nothing else in the chrome may borrow it. */
.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  height: 20px; padding: 1px 6px; border-radius: var(--r-2);
  background: linear-gradient(180deg, var(--surface-overlay), var(--surface-elev));
  color: var(--text-muted);
  font: 500 10px/1 var(--font-mono);
  box-shadow:
    0 1.5px 0.5px rgba(0, 0, 0, 0.4),
    0 0 0.5px 1px rgba(0, 0, 0, 0.9),
    inset 0 2px 1px rgba(0, 0, 0, 0.2),
    inset 0 1px 1px rgba(255, 255, 255, 0.12);
}
.light .kbd {
  background: linear-gradient(180deg, #ffffff, var(--surface-elev));
  box-shadow:
    0 1px 0.5px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

/* ── Theme toggle button (shared chrome) ── */
.theme-toggle {
  background: none; border: 1px solid var(--surface-rule); border-radius: var(--r-2);
  height: var(--control-h); padding: 0 10px; cursor: pointer; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tr-label); text-transform: uppercase;
  transition: border-color var(--t-base) var(--easing), color var(--t-base) var(--easing);
}
.theme-toggle:hover { border-color: var(--text-subtle); color: var(--text); }
/* Show the correct word + icon per theme (set by .light on <html>). */
.theme-toggle__dark, .theme-toggle__light { display: inline-flex; align-items: center; gap: 8px; }
.theme-toggle__light { display: none; }
.light .theme-toggle__light { display: inline-flex; }
.light .theme-toggle__dark  { display: none; }

/* ── Flash — quiet session-moment notice, fixed top-right ──
   Floating chrome, so the overlay physics apply: overlay surface + hairline
   + the one sanctioned shadow. Arrival is a quiet settle in from the right
   edge (a fade riding a nudge; base.css stills it under reduced motion).
   Info notices dismiss themselves after 6s via the colocated .FlashTimer
   hook, paused while the pointer or focus is on the card; errors persist. */
.flash-stack {
  position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: var(--z-chrome);
  display: flex; flex-direction: column; gap: var(--sp-2);
  width: 320px; max-width: calc(100vw - 2 * var(--sp-4));
}
.flash {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  background: var(--surface-overlay); border: 1px solid var(--line-strong);
  border-radius: var(--r-3); padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-overlay);
  animation: flash-in var(--t-base) var(--ease-out);
}
@keyframes flash-in {
  from { opacity: 0; transform: translateX(8px); }
}
.flash--error { border-left: 2px solid var(--danger); }
.flash__body { flex: 1; min-width: 0; }
.flash__kind {
  display: block; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: var(--tr-label); text-transform: uppercase;
  color: var(--text-subtle); margin-bottom: 4px;
}
.flash--error .flash__kind { color: var(--danger); }
.flash__message { font-size: 13px; line-height: 1.5; color: var(--text); }
/* The dismiss composes onto .icon-btn but stays compact and borderless
   inside the card (the double class also outranks the mobile 40px floor:
   the timer is the primary dismissal, the button the deliberate one). */
/* Self-sufficient: /auth pages load components.css without product.css,
   where the .icon-btn primitive lives, so the dismiss carries its basics. */
.flash__dismiss.icon-btn {
  background: none; cursor: pointer; border-radius: var(--r-2);
  height: 24px; min-height: 24px; min-width: 0; padding: 0 4px;
  border: 0; color: var(--text-subtle);
}
.flash__dismiss.icon-btn:hover { color: var(--text); }
