/* 02-base.css: the page, the bars, controls
   Part 3 of the app's styles.
   Sections:
   - Page and splash
   - Top bar and bottom bar
   - Controls: buttons, choices, switches
   - For screen readers only
*/

/* ==== Page and splash ==== */
* {
  box-sizing: border-box;
}
html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: var(--fz-m);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100vh;
  line-height: 1.45;
  /* room for the bars and the phone's own edges (notch, home indicator) */
  padding: calc(56px + env(safe-area-inset-top)) env(safe-area-inset-right) calc(72px + env(safe-area-inset-bottom))
    env(safe-area-inset-left);
}
/* the page stays hidden until main.js has drawn it (or 1.5 s pass), so nothing jumps */
html:not([data-ready]) body > :not(#splash) {
  visibility: hidden;
}
#splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg);
  color: var(--accent);
  font-size: var(--fz-xl);
  z-index: 50;
}
html[data-ready] #splash {
  display: none;
}
#main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 8px 16px 24px;
}

/* ==== Top bar and bottom bar ==== */
.top,
.bottom {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--bar);
  border-color: var(--rule);
  border-style: solid;
  border-width: 0;
}
.top {
  top: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: env(safe-area-inset-top) calc(12px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left));
  border-bottom-width: 1px;
}
.top h1 {
  margin: 0 8px;
  font-size: var(--fz-xl);
  font-weight: 600;
  outline-offset: 4px;
}
.bottom {
  bottom: 0;
  display: flex;
  justify-content: space-around;
  padding: 4px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-top-width: 1px;
}
.bottom button {
  flex: 1 1 0;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: var(--fz-xs);
}
.bottom button[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
}
.bottom .ic {
  font-size: var(--fz-xl);
  line-height: 1;
}

/* ==== Controls: buttons, choices, switches ==== */
button,
select,
input {
  font: inherit;
  color: inherit;
}
button {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 8px 16px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}
button.big {
  width: 100%;
  min-height: 52px;
  border: 0;
  background: var(--accent);
  color: var(--bg);
  font-size: var(--fz-l);
  font-weight: 600;
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
button.icon {
  border: 0;
  background: none;
  font-size: var(--fz-xxl);
  padding: 0;
}
:focus-visible {
  outline: 3px solid var(--you);
  outline-offset: 2px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap);
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}
.row label {
  flex: 1 1 auto;
}
select {
  min-height: var(--tap);
  max-width: 60%;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg);
}
.toggle input {
  width: 52px;
  height: 32px;
  accent-color: var(--accent);
}
@media (hover: hover) {
  button:not(:disabled):hover {
    filter: brightness(1.06);
  }
}

/* ==== For screen readers only ==== */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
