/* base.css: reset, page shell, focus rules, skip link, footer, tab bar.
   No web fonts: the system stack in tokens.css is used. */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--color-bg);
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  /* A focused element is never left hidden under the fixed tab bar. */
  scroll-padding-bottom: calc(var(--tabbar-h) + 16px);
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font: 500 var(--text-body) / 1.45 var(--font-body);
  overflow-wrap: break-word;
}

img, iframe { max-width: 100%; }

a { color: var(--color-accent-text); text-underline-offset: 3px; }
p { margin: 0 0 var(--space-3); }
h1, h2, h3 { margin: 0; }
ul, ol { margin: 0; padding: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Focus ---------------------------------------------------------------
   One visible ring everywhere: 3px dark orange, 2px offset. It is drawn
   outside the control, so on an orange-filled control the ring sits on the
   page or card behind it, never on the orange. Never removed. */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus);
  outline-offset: var(--focus-ring-offset);
}

/* <main> and the page <h1> take focus from code on navigation. A pointer user
   did not ask for a ring there, so :focus alone shows none; keyboard users
   (:focus-visible) always do. */
#view:focus:not(:focus-visible),
#page-title:focus:not(:focus-visible) { outline: none; }

/* --- Skip link: first in tab order, off-screen until focused ------------- */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: var(--space-2);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-4);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-weight: 700;
  border-radius: var(--radius-pill);
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }

/* --- Shell ---------------------------------------------------------------- */
.app-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) 6px;
}
.app-bar__logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-on-accent);
}
.app-bar__logo svg { width: 20px; height: 20px; }
.app-bar__title {
  margin: 0;
  font: 800 1.25rem / 1 var(--font-body);
  letter-spacing: -0.01em;
}
.app-bar__title span { color: var(--color-accent-text); }

.app-main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-2) var(--space-4) var(--space-4);
}

.noscript {
  margin: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-card-border);
  border-left: 4px solid var(--color-edge);
  border-radius: var(--radius);
}

/* --- Footer (every route; outside #view) ---------------------------------- */
.site-foot {
  width: calc(100% - 2 * var(--space-4));
  max-width: calc(var(--content-max) - 2 * var(--space-4));
  /* The bottom margin clears the fixed tab bar. */
  margin: var(--space-5) auto calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--space-4));
  padding: 14px var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius);
}
.site-foot p { margin: 0 0 var(--space-2); font-size: 0.9375rem; color: var(--color-muted); }
.site-foot .site-foot__safe { font-size: 1rem; font-weight: 700; color: var(--color-text); }
.site-foot .suggest { margin: var(--space-3) 0 0; }

/* --- Tab bar -------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  background: var(--color-surface);
  border-top: 1px solid var(--color-card-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: var(--content-max);
  margin: 0 auto;
  list-style: none;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-h);
  color: var(--color-muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border-top: 3px solid transparent;
}
.tab:focus-visible { outline-offset: -6px; }
.tab[aria-current="page"] { color: var(--color-accent-text); border-top-color: var(--color-accent-text); font-weight: 800; }
.tab__icon svg {
  display: block;
  width: 24px; height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
