/* base.css — Reset + global layout primitives. */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  line-height: var(--line-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-1);
  font-weight: 600;
  letter-spacing: -0.01em;
}

h1 {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
}

h2 {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
}

p {
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-2);
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-2) var(--space-6);
}

.app-header {
  text-align: center;
  margin-bottom: var(--space-3);
}

.app-header .tagline {
  max-width: 56ch;
  margin-inline: auto;
}

/* Frosted-glass panel surface, used by cards. */
.panel {
  background: var(--color-surface-translucent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-key-border);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* ---- Controls row: layout selector + inline history textbox ---- */
.controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.history-inline {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1 1 280px;
  min-width: 240px;
}

.history-box {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-key-border);
  border-radius: 10px;
  padding: 8px 12px;
  height: 40px;
}

.history-box::placeholder {
  color: var(--color-text-secondary);
}

/* ---- Segmented control (iOS UISegmentedControl style) ---- */
.segmented {
  display: inline-flex;
  background: var(--color-bg);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--color-key-border);
}

.segmented__option {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--color-text-secondary);
  font: inherit;
  font-size: 0.9rem;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--motion-release), color var(--motion-release);
}

.segmented__option[aria-pressed="true"] {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 1px 3px var(--color-key-shadow);
}

/* ---- Buttons ---- */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 500;
  border-radius: 980px;
  padding: 8px 18px;
  cursor: pointer;
  transition: transform var(--motion-press), background var(--motion-release);
}

.btn:active {
  transform: scale(0.97);
}

.btn--secondary {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

.btn--secondary:hover {
  background: color-mix(in srgb, var(--color-accent) 10%, transparent);
}

/* ---- Focus visibility (distinct from "pressed" key state) ---- */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* ---- Ad slots: neutral, clearly separated, reserved space ---- */
.ad-slot {
  display: block;
  background: var(--color-surface);
  border: 1px dashed var(--color-key-border);
  border-radius: var(--radius-card);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  text-align: center;
  align-content: center;
  margin: var(--space-3) auto;
  /* Reserve space before AdSense loads to prevent layout shift (CLS). */
  min-height: 90px;
}

.ad-slot--leaderboard {
  max-width: 728px;
}

.ad-slot--mobile-sticky {
  position: sticky;
  bottom: 0;
  z-index: 50;
  min-height: 50px;
}

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

.app-footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
}

.app-footer a {
  color: var(--color-accent);
}
