/* ════════════════════════════════════════════════════════════════════════
   Tactivela · core/base.css — APP SHELL LAYOUT + SHARED APP PIECES
   ────────────────────────────────────────────────────────────────────────
   The look comes from the design system (design/css/tokens.css and
   design/css/tactivela.css, loaded before this file). This file only adds
   what the app itself needs on top: the screen layout, sheet open/close,
   toast and save tick behaviour, print page, and a few small helpers.

   Rules: colours, sizes and corners come from --tk-* tokens only.
   Module styles live in each module's own .css, scoped under its class.
   ════════════════════════════════════════════════════════════════════════ */
html, body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; }
#app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* Every screen pads its sides by the side safe areas: the notch or Dynamic Island of an iPhone held
   sideways (0 in portrait, and in the Android app, which keeps the page clear of the cutout itself).
   Once, here, so no module pads for them and nothing inside a screen does it again. The app bar, hero
   and tab rail paint their colour out into this padding with box shadows, so they still reach the screen edges
   (design system 6.6, "Held sideways" in tactivela.css). A button placed straight in a screen with
   position: absolute is measured from the screen's edge, so it adds the inset itself (the add button below). */
#app > .screen { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; position: relative; background: var(--tk-bg);
  padding-left: var(--tk-safe-left); padding-right: var(--tk-safe-right); }
#app > .screen.active { display: flex; }
[hidden] { display: none !important; }

/* ── Small layout helpers ── */
.row { display: flex; gap: var(--tk-space-2); align-items: flex-end; }
.row > .grow, .grow { flex: 1; min-width: 0; }
.col { display: flex; flex-direction: column; gap: var(--tk-space-2); }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
/* In scrolling columns and sheets the content scrolls; nothing gets squashed. */
.scroll > *, .tk-sheet > * { flex-shrink: 0; }
.pad { padding: var(--tk-space-3); }
.gap-3 { gap: var(--tk-space-3); }
.note { font-size: var(--tk-fs-meta); color: var(--tk-text-subtle); line-height: 1.45; }

/* Icon button with no box (back arrows in app bars) */
.tk-btn--bare { border: 0; background: none; color: var(--tk-text); }
.tk-btn--bare:hover { color: var(--tk-violet); }
/* "Menu" back link used on full-screen tools */
.back-link { min-height: var(--tk-touch); display: flex; align-items: center; gap: 2px; padding: 0 6px 0 4px; border: 0; background: none; cursor: pointer;
  color: var(--tk-text-muted); font-family: var(--tk-font-display); font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.back-link:hover { color: var(--tk-text); }
/* Small round icon-only remove button (list rows) */
.x-btn { width: var(--tk-touch); height: var(--tk-touch); flex-shrink: 0; display: flex; align-items: center; justify-content: center; border: 0; border-radius: var(--tk-radius); background: none; color: var(--tk-text-subtle); cursor: pointer; }
.x-btn:hover { color: var(--tk-bad-text); background: var(--tk-bad-tint); }
.tk-crest { position: relative; text-transform: uppercase; }
.tk-crest input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tk-crest img { display: none; }
.tk-crest img.on { display: block; }
.tk-crest img.on ~ .tk-crest__ph { display: none; }
.tk-section-label { margin-top: var(--tk-space-2); }
.tk-empty p { margin: 0; font-size: var(--tk-fs-body-s); }
/* Selects: always the design-system field look */
select.tk-input { padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 20px) 20px, calc(100% - 14px) 20px; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }

/* ── Sheets (design system .tk-scrim / .tk-sheet), opened by TK.Shell ── */
.tk-scrim.mod-ov { display: none; }
.tk-scrim.mod-ov.op { display: flex; }
.tk-scrim.mod-ov.op > .tk-sheet { animation: tk-sheet-up var(--tk-dur-slow) var(--tk-ease); }
.tk-sheet--wide { max-width: 680px; }
.tk-sheet__actions { display: flex; gap: var(--tk-space-2); margin-top: var(--tk-space-1); }
.tk-sheet__actions > .tk-btn { flex: 1; }
@keyframes tk-sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }

/* ── "Are you sure?" sheet (TK.Shell.ask) ── */
.ask .ask-body { margin: 0; color: var(--tk-text-muted); line-height: 1.5; }
/* Headings and sheet titles take focus when a screen or sheet opens (so
   keyboard and screen-reader users start there); they are not controls. */
[tabindex="-1"]:focus { outline: none; }

/* ── Storage-full warning: stays until a save works (core/shell.js) ──
   Sits under the app bar and lets taps through, so nothing is blocked.
   Clear of the notch at the sides; below the compact app bar on a phone held sideways (tokens.css swaps --tk-appbar-h). */
.save-alert { position: fixed; left: calc(12px + var(--tk-safe-left)); right: calc(12px + var(--tk-safe-right)); top: calc(var(--tk-appbar-h) + 8px + var(--tk-safe-top)); z-index: var(--tk-z-toast);
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 4px 10px 12px; border-radius: var(--tk-radius); pointer-events: none;
  background: var(--tk-surface); border: var(--tk-border) solid var(--tk-bad); color: var(--tk-text);
  font-size: var(--tk-fs-body-s); line-height: 1.4; box-shadow: var(--tk-shadow-sheet); }
.save-alert > .tk-icon { color: var(--tk-bad-text); flex-shrink: 0; margin-top: 1px; }
.save-alert > span { flex: 1; }
.save-alert .x-btn { pointer-events: auto; margin: -8px 0; }

/* ── Environment tag on test deployments (core/boot.js; docs/STAGING.md) ──
   The app bars make room for it at their top (also the compact bar of a phone held sideways, whose
   height follows --tk-appbar-h); the tag sits in the top-left corner, clear of the notch. */
.env-labelled .tk-appbar { padding-top: calc(var(--tk-safe-top) + 14px); min-height: calc(var(--tk-appbar-h) + var(--tk-safe-top) + 14px); }
.env-tag { position: fixed; top: var(--tk-safe-top); left: var(--tk-safe-left); z-index: var(--tk-z-toast); pointer-events: none;
  padding: 1px 8px; border-radius: 0 0 var(--tk-radius-sm) 0; background: var(--tk-bad); color: var(--tk-on-accent);
  font-family: var(--tk-font-display); font-size: var(--tk-fs-micro); font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }

/* ── Toast + save tick (owned by core/shell.js) ── */
.tk-toast { opacity: 0; pointer-events: none; white-space: nowrap; transition: opacity var(--tk-dur-slow) var(--tk-ease); }
.tk-toast.on { opacity: 1; }
.sav { position: fixed; top: calc(6px + var(--tk-safe-top)); left: calc(50% + (var(--tk-safe-left) - var(--tk-safe-right)) / 2); transform: translateX(-50%); z-index: var(--tk-z-toast);
  padding: 2px 10px; border-radius: var(--tk-radius-pill); background: var(--tk-ok-tint); color: var(--tk-ok);
  font-family: var(--tk-font-display); font-size: var(--tk-fs-label); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  opacity: 0; transition: opacity var(--tk-dur-slow) var(--tk-ease); pointer-events: none; }
.sav.on { opacity: 1; }
/* A short landscape screen (the compact one-line app bar, design system 6.6): the bar has no free strip
   above the title, and its one line holds the title, eyebrow and sub-line. So on a screen with an app bar
   the tick straddles the touchline under the bar instead (its centre on the line: the bar's bottom edge
   less half the tick's 21px and half the 3px line), clear of every word in the bar; the app bar is 14px
   taller on a test deployment, so the tick moves down with it. A screen with a hero instead (the menu,
   sign-in) or the onboarding bar keeps the strip above, as held upright. Opaque here (its tint over the
   surface), as it may cross the line or the edge of what is below. A browser without :has() keeps the
   tick at the top. */
@media (orientation: landscape) and (max-height: 500px) {
  .sav { background: linear-gradient(var(--tk-ok-tint), var(--tk-ok-tint)), var(--tk-surface); }
  body:has(#app > .screen.active > .tk-appbar) .sav { top: calc(var(--tk-safe-top) + var(--tk-appbar-h) - var(--tk-space-3)); }
  .env-labelled body:has(#app > .screen.active > .tk-appbar) .sav { top: calc(var(--tk-safe-top) + var(--tk-appbar-h) + 14px - var(--tk-space-3)); }
}

/* ── Add button: sits inside its screen or tab, clear of the bottom nav and the notch ──
   One straight in a screen is measured from the screen's edge, so it adds the side inset the screen
   pads by; one in a workspace tab is already inside that padding. From 700px the tabs are a rail on
   the left, so a tab runs to the bottom edge and its button stays above the home indicator.
   :where() keeps the screen rule as weak as .tk-fab (0,1,0), so a module's own placement of its
   button (".ss .tk-fab": by the column on a tablet or PC) still wins; such a rule adds the inset itself. */
.tk-fab { position: absolute; right: var(--tk-space-4); bottom: calc(16px + var(--tk-safe-bottom)); z-index: 10; }
:where(#app > .screen) > .tk-fab { right: calc(var(--tk-space-4) + var(--tk-safe-right)); }
.ws-panel .tk-fab { bottom: 16px; }
@media (min-width: 700px) {
  .ws-panel .tk-fab { bottom: calc(16px + var(--tk-safe-bottom)); }
}

/* ── Print (core/shell.js owns #ps; modules style their own page class) ── */
#ps { display: none; }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  html, body { height: auto; overflow: visible; }
  body::before { display: none; }
  body > *:not(#ps) { display: none !important; }
  #ps { display: block !important; }
}
