/* shell.css — app frame: skip link, sticky header (wordmark, section tabs,
   theme toggle), main and footer. Header, pages and footer share one
   1200px container with the same gutters (--gutter). */

:root { --gutter: var(--space-6); --header-h: 52px; }
@media (max-width: 640px) { :root { --gutter: var(--space-4); } }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: var(--space-4); top: var(--space-2); z-index: 100;
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  background: var(--fizz); color: var(--on-fizz); font: 600 14px/20px var(--font-sans);
  text-decoration: none; transform: translateY(-200%);
}
.skip-link:focus, .skip-link:focus-visible { transform: none; outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header__inner {
  max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter); min-height: var(--header-h);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand nav actions"; align-items: center; column-gap: var(--space-6);
}

.app-wordmark {
  grid-area: brand; display: inline-flex; align-items: baseline; gap: 1px;
  color: var(--ink); text-decoration: none; white-space: nowrap; border-radius: var(--radius-sm);
}
.app-wordmark:hover { color: var(--ink); text-decoration: none; }
.app-wordmark:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.app-wordmark__icon { width: 24px; height: 24px; align-self: center; margin-right: 6px; flex: none; }
.app-wordmark__name { font: 800 20px/24px var(--font-display); letter-spacing: -0.01em; }
.app-wordmark__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fizz); margin: 0 1px; }
.app-wordmark__tld { font: 700 20px/24px var(--font-display); color: var(--ink-muted); letter-spacing: -0.01em; }

/* Section tabs: one clean segmented row. */
.app-nav { grid-area: nav; min-width: 0; display: flex; }
.app-tabs {
  display: inline-flex; gap: 2px; padding: 3px; max-width: 100%;
  border: 1px solid var(--border); border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--surface); overflow-x: auto;
}
.app-tabs::-webkit-scrollbar { display: none; }
.app-tab {
  padding: 5px 12px; margin: 0; border: 0; border-radius: 9px;
  font: 600 13px/20px var(--font-sans); color: var(--ink-muted); text-decoration: none;
}
.app-tab:hover { text-decoration: none; background: var(--surface-raised); color: var(--ink); }
.app-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.app-tab .mc-ico { width: 14px; font-size: 13px; color: inherit; }
.app-tab[aria-current="page"] {
  color: var(--ink); background: var(--surface-raised);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.app-tab[aria-current="page"] .mc-ico { color: var(--fizz-text); }
.app-tab .mc-tab__count { padding: 0 6px; font-size: 11px; line-height: 16px; }
.app-tab[aria-current="page"] .mc-tab__count { background: var(--fizz); color: var(--on-fizz); }

.app-header__actions { grid-area: actions; display: flex; align-items: center; gap: var(--space-2); }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  appearance: none; cursor: pointer; display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: transparent; color: var(--ink-muted);
  font-size: 15px; transition: background-color 120ms ease-out, color 120ms ease-out;
}
.theme-toggle:hover { background: var(--surface-raised); color: var(--ink); }
.theme-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Main and footer ---------- */
.app-main { display: block; min-height: calc(100vh - var(--header-h) - 64px); }
.app-main:focus { outline: none; }

.app-footer { border-top: 1px solid var(--border); margin-top: var(--space-8); }
.app-footer__inner {
  max-width: 1200px; margin: 0 auto; padding: var(--space-4) var(--gutter);
  display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4);
  font: 400 13px/20px var(--font-sans); color: var(--ink-muted);
}
.app-footer__inner a { color: var(--grape); }

.app-tab__short { display: none; }

/* ---------- Account menu (account.rs) ---------- */
.acct { position: relative; }
.acct__btn {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-2);
  height: 34px; max-width: 220px; padding: 0 10px 0 3px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: transparent; color: var(--ink);
  font: 600 13px/20px var(--font-sans); transition: background-color 120ms ease-out;
}
.acct__btn:hover, .acct__btn[aria-expanded="true"] { background: var(--surface-raised); }
.acct__btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.acct__avatar {
  flex: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--radius-pill);
  background: var(--grape-wash); color: var(--ink); font: 800 11px/1 var(--font-display); letter-spacing: .02em;
  box-shadow: inset 0 0 0 1px var(--grape);
}
.acct__avatar--lg { width: 36px; height: 36px; font-size: 13px; }
.acct--loading .acct__avatar { background: var(--surface-raised); box-shadow: none; }
.acct__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct__chev { font-size: 10px; color: var(--ink-muted); }
.acct__backdrop { position: fixed; inset: 0; z-index: 60; }
.acct__menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 61; width: 288px; max-width: calc(100vw - 2 * var(--gutter));
  padding: var(--space-2); border-radius: var(--radius-lg); border: 1px solid var(--border-strong);
  background: var(--surface); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: 2px;
}
.acct__who { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border); margin-bottom: var(--space-1); }
.acct__whotext { display: flex; flex-direction: column; min-width: 0; }
.acct__id { font: 600 14px/20px var(--font-sans); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct__via { font: 400 12px/16px var(--font-sans); color: var(--ink-muted); }
.acct__links { display: flex; flex-direction: column; gap: 2px; }
.acct__links > span { display: contents; }
.acct__item {
  display: flex; align-items: center; gap: var(--space-3); padding: 8px var(--space-2); border-radius: var(--radius-sm);
  font: 600 14px/20px var(--font-sans); color: var(--ink); text-decoration: none;
}
.acct__item > i { width: 16px; text-align: center; font-size: 14px; color: var(--ink-muted); }
.acct__item:hover { background: var(--surface-raised); color: var(--ink); text-decoration: none; }
.acct__item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.acct__setting { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: var(--space-1) 0; padding: var(--space-1) 0; }
.acct__toggle { padding: 2px var(--space-2) var(--space-1); border-radius: var(--radius-sm); }
.acct__toggle:hover { background: var(--surface-raised); }
.acct__toggle .mc-toggle__desc { font-size: 12px; line-height: 16px; }
.acct__err { margin: 0; padding: 0 var(--space-2) var(--space-2); font: 400 12px/16px var(--font-sans); color: var(--danger-text); }
.acct__signout { color: var(--ink-muted); }

.acct-out { margin-top: var(--space-8); }
.acct-out .mc-empty__title { font-size: 20px; line-height: 28px; }

/* ---------- Medium: tab icons go first, then the account name ---------- */
@media (max-width: 1360px) {
  .app-tab .mc-ico { display: none; }
  .app-header__inner { column-gap: var(--space-4); }
}
@media (max-width: 1120px) {
  .acct__name, .acct__chev { display: none; }
  .acct__btn { padding: 0 3px; border-color: transparent; }
}

/* ---------- Wide: eight tabs fit in the 1200px frame only with the short labels ---------- */
@media (min-width: 641px) {
  .app-tab { padding: 5px 5px; }
  .app-tab .mc-ico { display: none; }
  .app-tab:has(.app-tab__short) .app-tab__label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  .app-tab__short { display: inline; }
}

/* ---------- Narrow: brand + toggle on top, tabs fill a second row ---------- */
@media (max-width: 640px) {
  .app-header__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions" "nav nav";
    row-gap: 0; min-height: 0;
  }
  .app-wordmark, .app-header__actions { height: 48px; align-items: center; }
  .app-nav { padding-bottom: var(--space-2); }
  /* eight tabs don't fit: the row scrolls, faded at the right edge */
  .app-tabs { display: flex; width: 100%; scrollbar-width: none; scroll-padding: 0 24px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent); }
  .app-tabs { position: relative; }
  .app-tab { position: relative; flex: 1 0 auto; justify-content: center; padding: 5px 10px; gap: 6px; }
  .app-tab:last-child { margin-right: 20px; }
  /* long label stays readable by screen readers, short one is shown */
  .app-tab:has(.app-tab__short) .app-tab__label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  .app-tab__short { display: inline; }
}
/* ---------- Desktop: the section tabs become a vertical sidebar ----------
   Below 1024px (tablets, phones) the header row above is unchanged. */
:root { --sidebar-w: 224px; }
@media (min-width: 1024px) {
  /* no backdrop-filter here: it would make the fixed sidebar relative to the header */
  .app-header { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .app-header__inner {
    max-width: none; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand actions";
  }
  .app-nav {
    position: fixed; top: calc(var(--header-h) + 1px); bottom: 0; left: 0; width: var(--sidebar-w);
    padding: var(--space-4) var(--space-3); overflow-y: auto; overscroll-behavior: contain;
    border-right: 1px solid var(--border); background: var(--bg);
  }
  .app-tabs {
    display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 0;
    border: 0; border-radius: 0; background: transparent; overflow: visible;
  }
  .app-tab {
    display: flex; align-items: center; gap: var(--space-3); width: 100%; padding: 8px 10px;
    border-radius: var(--radius-sm); font-size: 14px;
  }
  /* full labels and icons: there is room now */
  .app-tab .mc-ico { display: inline-block; width: 16px; font-size: 14px; text-align: center; }
  .app-tab:has(.app-tab__short) .app-tab__label {
    position: static; width: auto; height: auto; overflow: visible; clip: auto;
  }
  .app-tab__short { display: none; }
  .app-tab .mc-tab__count { margin-left: auto; }
  .app-tab[aria-current="page"] { box-shadow: inset 3px 0 0 var(--fizz), inset 0 0 0 1px var(--border); }
  /* the page, banners and footer sit to the right of the sidebar */
  .app-header:has(.app-nav) ~ .app-banners,
  .app-header:has(.app-nav) ~ .app-main,
  .app-header:has(.app-nav) ~ .app-footer { margin-left: var(--sidebar-w); }
}

@media (max-width: 420px) {
  .app-tab:has(.app-tab__short) .mc-tab__count { display: none; }
  .app-footer__inner { flex-direction: column; align-items: flex-start; }
  .app-footer__inner.mc-meta > * + *::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle, .acct__btn { transition: none; }
}
