/* Blazor "Fluent" (SPEC 7.7 as amended). Fluent UI Blazor 5 tokens for every neutral, .NET purple
   as the brand through the theme service, Selawik through the body font token, the Fluent type
   ramp (12, 14, 16, 20, 28). Space 4 8 12 16 20 24; radius 4 (cards, controls) and 8 (lanes). */

@font-face { font-family: "Selawik"; font-weight: 400; font-display: swap; src: url("../fonts/Selawik-400.woff2") format("woff2"); unicode-range: U+0000-2025, U+2027-FFFF; }
@font-face { font-family: "Selawik"; font-weight: 600; font-display: swap; src: url("../fonts/Selawik-600.woff2") format("woff2"); unicode-range: U+0000-2025, U+2027-FFFF; }

:root {
  --ss-success: #107C10; --ss-danger: #C50F1F; --ss-warning: #8A5800;
  --ss-bar: 48px; --ss-status: 28px; --ss-gutter: 24px;
}
body {
  --fontFamilyBase: "Selawik", "Segoe UI", system-ui, sans-serif;
  margin: 0; font-family: var(--fontFamilyBase); font-size: 14px; line-height: 20px;
  background: var(--colorNeutralBackground2, #FAFAFA); color: var(--colorNeutralForeground1, #242424);
}
body[data-theme="dark"] {
  --colorNeutralForegroundOnBrand: #1F1F1F;
  --ss-success: #54B054; --ss-danger: #F1707B; --ss-warning: #E0B03A;
}
*, *::before, *::after { box-sizing: border-box; }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Fluent focus: 2 px outer stroke, 1 px inner stroke, inverse in dark (the theme's focus tokens) */
.card-slot:focus-visible, .compact-row:focus-visible, .field:focus-visible, .select-all:focus-visible {
  outline: 2px solid var(--colorStrokeFocus2, #000000); outline-offset: 0;
  box-shadow: inset 0 0 0 1px var(--colorStrokeFocus1, #FFFFFF);
}

/* boot (before .NET starts) and loading */
.boot, .loading { display: flex; align-items: center; gap: 12px; padding: 24px; color: var(--colorNeutralForeground2, #616161); }
.boot-ring { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #E0E0E0; border-top-color: #512BD4; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---- frame ---- */
.app { min-height: 100dvh; padding-bottom: calc(var(--ss-status) + env(safe-area-inset-bottom)); }
.titlebar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; height: var(--ss-bar);
  padding: 0 max(var(--ss-gutter), env(safe-area-inset-right)) 0 max(var(--ss-gutter), env(safe-area-inset-left));
  background: var(--colorNeutralBackground1, #FFFFFF); border-bottom: 1px solid var(--colorNeutralStroke2, #E0E0E0);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 20px; line-height: 28px; font-weight: 600; }
.titlebar-end { display: flex; gap: 4px; }

.commandbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 52px;
  padding: 8px var(--ss-gutter); background: var(--colorNeutralBackground1, #FFFFFF);
  border-bottom: 1px solid var(--colorNeutralStroke2, #E0E0E0);
}
.composer { display: flex; gap: 8px; align-items: center; flex: 0 1 420px; min-width: 0; }
.field {
  flex: 1; min-width: 0; height: 32px; padding: 0 10px; font: inherit; color: inherit;
  background: var(--colorNeutralBackground1, #FFFFFF); border: 1px solid var(--colorNeutralStrokeAccessible, #616161);
  border-radius: 4px;
}
.field::placeholder { color: var(--colorNeutralForeground3, #707070); }
.field.invalid { border-color: var(--ss-danger); }
.field-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.field-message {
  position: absolute; z-index: 7; top: calc(100% + 4px); left: 0; right: 0; display: flex; gap: 6px; align-items: flex-start;
  padding: 6px 8px; font-size: 12px; line-height: 16px; color: var(--colorNeutralForeground1, #242424);
  background: var(--colorNeutralBackground1, #FFFFFF); border: 1px solid var(--ss-danger); border-radius: 4px; box-shadow: var(--shadow4);
}
.field-error { margin: 0; color: var(--ss-danger); font-size: 12px; line-height: 16px; }
.selection-commands { display: flex; align-items: center; gap: 4px; }
.divider { width: 1px; height: 20px; margin: 0 4px; background: var(--colorNeutralStroke2, #E0E0E0); }
.selection-count { margin-left: 8px; color: var(--colorNeutralForeground2, #616161); font-size: 12px; }
.more-commands { display: none; }

.content { padding: 12px var(--ss-gutter) 24px; }
.views { width: 100%; }

/* ---- the board: three lanes of Fluent cards ---- */
.lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; margin-top: 12px; }
/* the unreachable state: Fluent's stack gap between heading, text and button (BZ-C1) */
.unreachable { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.unreachable h2, .unreachable p { margin: 0; }
.lane { padding: 12px; background: var(--colorNeutralBackground3, #F5F5F5); border-radius: 8px; min-height: 160px; }
.lane-head { display: flex; align-items: center; gap: 8px; margin: 0 4px 12px; }
.lane-head h2 { font-size: 14px; line-height: 20px; font-weight: 600; }
.count {
  min-width: 20px; padding: 0 6px; border-radius: 4px; text-align: center; font-size: 12px; line-height: 20px;
  background: var(--colorNeutralBackground1, #FFFFFF); color: var(--colorNeutralForeground2, #616161); font-variant-numeric: tabular-nums;
}
.cards { display: grid; gap: 8px; }
.card-slot { position: relative; border-radius: 4px; cursor: default; }
.fcard { position: relative; display: grid !important; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 4px; padding: 12px 4px 12px 16px !important; border-radius: 4px !important; }
.fcard.selected { box-shadow: var(--shadow8), inset 2px 0 0 var(--colorBrandBackground, #512BD4); }
.card-title { font-size: 16px; line-height: 22px; font-weight: 600; overflow-wrap: normal; word-break: normal; hyphens: auto; hyphenate-limit-chars: 8 4 4; }
.card-meta { margin-top: 4px; font-size: 12px; line-height: 16px; color: var(--colorNeutralForeground2, #616161); }
.check { position: absolute; bottom: 8px; right: 8px; color: var(--colorBrandForeground1, #512BD4); display: inline-flex; }
.card-actions { grid-column: 2; grid-row: 1; margin-top: -6px; }
.rename { grid-column: 1 / -1; }
.rename { display: grid; gap: 8px; padding-right: 0; }
.rename .field { width: 100%; }
.rename .field-error { margin: 0; }
.rename-actions { display: flex; gap: 8px; }
.empty { padding: 16px; border: 1px dashed var(--colorNeutralStroke1, #D1D1D1); border-radius: 4px; color: var(--colorNeutralForeground2, #616161); }
.empty-title { color: var(--colorNeutralForeground1, #242424); font-weight: 600; }

/* ---- the grid ---- */
.grid-wrap { margin-top: 12px; background: var(--colorNeutralBackground1, #FFFFFF); border: 1px solid var(--colorNeutralStroke2, #E0E0E0); border-radius: 8px; overflow-x: auto; }
.compact-list { margin-top: 12px; background: var(--colorNeutralBackground1, #FFFFFF); border-radius: 8px; }
.compact-row { display: grid; gap: 2px; padding: 12px 16px; min-height: 56px; border-bottom: 1px solid var(--colorNeutralStroke2, #E0E0E0); }
.row-title { font-weight: 600; hyphens: auto; }
.row-meta { font-size: 12px; line-height: 16px; color: var(--colorNeutralForeground2, #616161); }

/* ---- the status bar ---- */
.statusbar {
  position: fixed; inset: auto 0 0 0; z-index: 5; display: flex; align-items: center; gap: 24px;
  min-height: var(--ss-status); padding: 4px var(--ss-gutter) calc(4px + env(safe-area-inset-bottom));
  background: var(--colorNeutralBackground3, #F5F5F5); border-top: 1px solid var(--colorNeutralStroke2, #E0E0E0);
  font-size: 12px; line-height: 16px; color: var(--colorNeutralForeground2, #616161);
}
.status-cell { white-space: nowrap; }
.connection { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--colorNeutralForeground3, #707070); }
.connection.live .dot { background: var(--ss-success); }
.connection.lost .dot { background: var(--ss-warning); }

/* ---- toast ---- */
.toast-dock { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(var(--ss-status) + 16px + env(safe-area-inset-bottom)); }
.toast {
  display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px; white-space: nowrap;
  background: var(--colorNeutralBackgroundInverted, #292929); color: var(--colorNeutralForegroundInverted, #FFFFFF);
  border-radius: 4px; box-shadow: var(--shadow16);
}
.toast .undo { color: var(--colorBrandForegroundInverted, #A48BFF); }

/* ---- dialogs ---- */
.about { display: grid; gap: 16px; }
.about p { max-width: 64ch; }
.about-marks { display: flex; gap: 8px; }
.facts, .keys { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; }
.facts dt, .keys dd { color: var(--colorNeutralForeground2, #616161); }
.about h3 { font-size: 14px; line-height: 20px; font-weight: 600; }
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.files code, kbd { font-family: Consolas, ui-monospace, monospace; font-size: 12px; }
kbd { color: var(--colorNeutralForeground1, #242424); padding: 1px 6px; border: 1px solid var(--colorNeutralStroke1, #D1D1D1); border-bottom-width: 2px; border-radius: 4px; background: var(--colorNeutralBackground1, #FFFFFF); }

#blazor-error-ui { display: none; position: fixed; inset: auto 0 0 0; z-index: 1000; padding: 12px var(--ss-gutter); background: var(--colorNeutralBackground1, #FFFFFF); color: var(--ss-danger); border-top: 1px solid var(--ss-danger); }
#blazor-error-ui .dismiss { margin-left: 16px; }

/* ---- tablet (600 to 1023) ---- */
@media (max-width: 1023px) { :root { --ss-gutter: 16px; } .lanes { gap: 12px; } .lane { padding: 8px; } .divider { display: none; } }

/* ---- phone (under 600): New card plus More; columns as tabs; the grid as a list ---- */
@media (max-width: 599px) {
  .label-wide { display: none; }
  .composer { flex: 1 1 auto; }
  .selection-commands { display: none; }
  .more-commands { display: block; }
  .statusbar .runtime, .statusbar .status-cell:first-child { display: none; }
  .facts, .keys { grid-template-columns: 1fr; gap: 4px; }
  .facts dd, .keys dd { margin-bottom: 8px; }
}

/* ---- coarse pointers: 44 px targets, 16 px inputs ---- */
@media (pointer: coarse) {
  .field { height: 44px; font-size: 16px; }
  fluent-button { min-height: 44px; min-width: 44px; }
  .titlebar-end, .selection-commands, .composer, .rename-actions { gap: 8px; }
}

/* ---- the tile (?embed=1, 420 x 640): the three-lane board with the status bar ---- */
.tile { --ss-gutter: 12px; --ss-bar: 40px; --ss-status: 24px; height: 640px; overflow: hidden; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; padding-bottom: 0; }
.tile .brand h1 { font-size: 16px; line-height: 22px; }
.tile .hide-tile, .tile .label-wide, .tile .selection-commands { display: none; }
.tile .more-commands { display: block; }
.tile .commandbar { min-height: 0; padding: 6px var(--ss-gutter); }
.tile .composer { flex: 1 1 auto; }
.tile .content { padding: 8px var(--ss-gutter); min-height: 0; overflow: hidden; }
.tile .lanes { gap: 6px; margin: 0; height: 100%; }
.tile .lane { padding: 6px; min-height: 0; height: 100%; overflow-y: auto; overflow-x: hidden; }
/* rename in a narrow tile column: the field shrinks to the column, Save and Cancel stack under it (B-E51 B3) */
.tile .rename, .tile .rename .field { min-width: 0; }
.tile .rename-actions { flex-direction: column; gap: 4px; }
.tile .rename-actions > * { width: 100%; min-width: 0; }
.tile .lane-head { margin: 0 2px 6px; }
.tile .lane-head h2 { font-size: 12px; line-height: 16px; }
.tile .cards { gap: 4px; }
.tile .fcard { padding: 6px 2px 6px 8px !important; }
.tile .card-title { font-size: 12px; line-height: 16px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tile .card-meta, .tile .check { display: none; }
.tile .card-actions { margin-top: -4px; }
.tile .empty { padding: 8px; font-size: 12px; line-height: 16px; }
.tile .statusbar { position: static; gap: 12px; padding: 4px var(--ss-gutter); }
.tile .statusbar .runtime, .tile .statusbar .status-cell:first-child { display: none; }
.tile .toast-dock { bottom: 40px; }

@media (prefers-reduced-motion: reduce) { .boot-ring { animation: none; } }

.sheet-full { border-radius: 0 !important; margin: 0 !important; max-width: 100vw !important; max-height: 100dvh !important; }
fluent-dialog.sheet-full::part(dialog) { width: 100vw !important; max-width: 100vw !important; height: 100dvh !important; max-height: 100dvh !important; margin: 0 !important; border-radius: 0 !important; }
.column-pick { width: 132px; justify-content: space-between; }
.select-all { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--borderRadiusMedium, 4px); background: transparent; color: inherit; cursor: pointer; }
.grid-wrap td[role="gridcell"] { text-overflow: clip; }
/* tooltips are hover feedback: never on a touch screen, where a tap would leave them stuck (R-57) */
@media (hover: none), (pointer: coarse) { fluent-tooltip { display: none !important; } }
.keys kbd { color: var(--colorNeutralForeground1) !important; }
.write-error { display: flex; align-items: center; gap: 8px; margin: 8px var(--ss-gutter) 0; padding: 6px 8px 6px 12px; border: 1px solid var(--ss-danger); border-radius: 4px; background: var(--colorNeutralBackground1, #FFFFFF); font-size: 12px; line-height: 16px; }
.card-slot.landed .fcard { box-shadow: var(--shadow8), 0 0 0 2px var(--colorBrandStroke1, #512BD4) !important; transition: box-shadow 900ms ease-out; }
@media (prefers-reduced-motion: reduce) { .card-slot.landed .fcard { transition: none; } }
