/* ==========================================================================
   shell.css — the frame, the top bar, the action bar, the tab bar.
   One sticky action bar, never stacked on a second sticky element.
   ========================================================================== */

/* The app sits in a 430px column on a full-bleed ink field above 720px —
   a device on a table. Below that it is the whole viewport. */
.app {
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (min-width: 721px) {
  body { background: var(--ink); }
  .app {
    min-height: 100dvh;
    box-shadow: 0 0 0 1px var(--hairline);
  }
}

/* TK-003: a 6px inset border as a print reference. One rule, reads as designed. */
.frame {
  position: fixed;
  inset: 0;
  border: var(--frame) solid var(--ink);
  pointer-events: none;
  z-index: 60;
}

@media (min-width: 721px) { .frame { display: none; } }

/* ---- top bar ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) var(--gutter) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}

.topbar-back {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  min-width: var(--tap);
  margin-left: calc(var(--s-3) * -1);
  padding-inline: var(--s-3);
}

.topbar-title {
  flex: 1;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar-wordmark {
  font-family: var(--font-display);
  font-size: 1.375rem;
  letter-spacing: 0.02em;
  font-variation-settings: 'opsz' 40, 'WONK' 1;
  /* It is a link home, so it is a tap target. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
}

.topbar-search {
  min-height: var(--tap);
  min-width: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  margin-right: calc(var(--s-3) * -1);
  padding-inline: var(--s-3);
}

/* ---- outlet -------------------------------------------------------------- */

.outlet {
  flex: 1;
  padding-bottom: calc(var(--tabbar-h) + var(--actionbar-h) + var(--safe-b) + var(--s-6));
}

/* ---- action bar ---------------------------------------------------------- */
/* ONE bar. State-driven contents. Above the tab bar, clear of the safe area. */

.actionbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-b));
  width: 100%;
  max-width: var(--app-max);
  z-index: 25;
  background: var(--paper);
  border-top: 1px solid var(--hairline);
  padding: var(--s-3) var(--gutter);
  display: none;
}

.actionbar.is-live { display: block; }

.actionbar-inner {
  display: flex;
  align-items: center;
  gap: var(--s-4);
}

.actionbar-meta { flex: 1; min-width: 0; }
.actionbar-meta .t-label { display: block; }
.actionbar-total { font-variant-numeric: tabular-nums; }

/* ---- tab bar ------------------------------------------------------------- */
/* Five destinations. The count is not negotiable. */

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--app-max);
  z-index: 26;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--paper);
  border-top: 1px solid var(--ink);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  /* "ACCOUNT" at 12px + 0.1em tracking overruns a 75px cell at 375px. */
  font-size: clamp(0.625rem, 2.7vw, 0.75rem);
  letter-spacing: clamp(0.02em, 0.6vw, 0.1em);
  text-transform: uppercase;
  font-weight: var(--w-bold);
  color: var(--ink-muted);
  background-image: none;
  position: relative;
  padding-inline: 2px;
  text-align: center;
}

.tab[aria-current="page"] { color: var(--ink); }

.tab[aria-current="page"]::after {
  content: '';
  position: absolute;
  top: 0;
  left: 22%;
  right: 22%;
  height: 2px;
  background: var(--accent);
}

/* ---- sheet --------------------------------------------------------------- */

.sheet-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--scrim);
  opacity: 0;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: var(--app-max);
  max-height: 86dvh;
  z-index: 71;
  background: var(--paper);
  border-top: 1px solid var(--ink);
  /* The single permitted exception to radius 0, at 2px. */
  border-radius: 2px 2px 0 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -1px 0 var(--scrim-soft);
  padding-bottom: var(--safe-b);
}

@media (prefers-reduced-motion: no-preference) {
  .sheet-scrim { transition: opacity var(--d-state) var(--ease-inout); }
  .sheet { transition: transform 320ms var(--ease-out); }
}

.sheet-scrim.is-open { opacity: 1; }
.sheet.is-open { transform: translate(-50%, 0); }

.sheet-grip {
  width: 34px;
  height: 2px;
  background: var(--hairline);
  margin: var(--s-3) auto var(--s-1);
}

.sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-3) var(--gutter) var(--s-3);
  border-bottom: 1px solid var(--hairline);
}

.sheet-close { color: var(--ink-muted); min-height: var(--tap); }
.sheet-body { overflow-y: auto; padding: var(--s-5) var(--gutter); }
.sheet-foot { border-top: 1px solid var(--hairline); padding: var(--s-3) var(--gutter); }

/* ---- toast --------------------------------------------------------------- */

.toast-host {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--actionbar-h) + var(--safe-b) + var(--s-4));
  width: 100%;
  max-width: var(--app-max);
  padding-inline: var(--gutter);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--ink);
  color: var(--paper);
  padding: var(--s-3) var(--s-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  font-size: var(--t-small);
  opacity: 0;
  transform: translateY(6px);
}

@media (prefers-reduced-motion: no-preference) {
  .toast { transition: opacity var(--d-state) var(--ease-inout), transform var(--d-state) var(--ease-inout); }
}

.toast.is-open { opacity: 1; transform: translateY(0); }
.toast-undo { color: var(--paper); text-decoration: underline; min-height: 32px; }

/* ---- noscript ------------------------------------------------------------ */

.noscript { padding-block: var(--s-7); }
.noscript h2 { margin-top: var(--s-6); }
.noscript ul { margin-top: var(--s-3); }
.noscript li { padding-block: var(--s-2); border-bottom: 1px solid var(--hairline); }
