/* Spanish cards synthetic preview (U1). Dependency-free mobile-first styles. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6675;
  --accent: #0f62d6;
  --accent-contrast: #ffffff;
  --border: #c9d2dd;
  --danger: #a4262c;
  --focus: #0b4fa8;
  --gap: 12px;
  --control-min: 44px;
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #14181f;
  --surface: #1d232d;
  --text: #e8ecf2;
  --muted: #a4aebc;
  --accent: #6ea8ff;
  --accent-contrast: #0d1220;
  --border: #3a4452;
  --danger: #ff8a8f;
  --focus: #9cc2ff;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #14181f;
    --surface: #1d232d;
    --text: #e8ecf2;
    --muted: #a4aebc;
    --accent: #6ea8ff;
    --accent-contrast: #0d1220;
    --border: #3a4452;
    --danger: #ff8a8f;
    --focus: #9cc2ff;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  /* Mobile safe areas */
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

main,
.app-header,
.app-footer,
.tabs {
  width: 100%;
  max-width: 480px;
  margin-inline: auto;
  padding-inline: max(16px, env(safe-area-inset-left));
}

.app-header {
  position: relative;
  padding-top: 16px;
  padding-bottom: 8px;
}

.app-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.app-badge.inline {
  margin: 0 0 8px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.app-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.theme-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  min-width: var(--control-min);
  min-height: var(--control-min);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 1.125rem;
  cursor: pointer;
}

[data-theme='dark'] .theme-label-light,
:root:not([data-theme]) .theme-label-light {
  display: none;
}

[data-theme='dark'] .theme-label-dark,
:root:not([data-theme]) .theme-label-dark {
  display: inline;
}

[data-theme='light'] .theme-label-light {
  display: inline;
}

[data-theme='light'] .theme-label-dark {
  display: none;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-label-light {
    display: inline;
  }

  :root:not([data-theme]) .theme-label-dark {
    display: none;
  }
}

.tabs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.tab {
  flex: 1;
  min-height: var(--control-min);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected='true'] {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

main {
  flex: 1;
  padding-block: 12px 24px;
}

section[role='tabpanel'] {
  outline: none;
}

.status-text {
  min-height: 1.5em;
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.status-text.error {
  color: var(--danger);
  font-weight: 600;
}

.card {
  margin: 0;
  padding: 24px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}

.card-front {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.card-answer {
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

button {
  font-family: inherit;
}

button:focus-visible,
[role='tabpanel']:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.primary,
.secondary {
  flex: 1 1 auto;
  min-height: var(--control-min);
  min-width: var(--control-min);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.ratings {
  margin-top: 24px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}

.ratings-heading {
  margin: 0;
  font-size: 1.125rem;
}

.ratings-note {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 600;
}

.rating-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: max(8px, var(--gap));
}

.rating {
  min-height: var(--control-min);
  min-width: var(--control-min);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}

kbd {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.8125rem;
}

#panel-progress h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

#panel-progress h3 {
  margin: 20px 0 8px;
  font-size: 1rem;
}

#progress-summary {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.progress-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.progress-totals div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.progress-totals dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.progress-totals dd {
  margin: 2px 0 0;
  font-size: 1.375rem;
  font-weight: 700;
}

.progress-buckets {
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress-buckets li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 8px;
}

.app-footer {
  padding-block: 12px 16px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.app-footer p {
  margin: 0;
}

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

/* 200% text zoom without clipping */
@media (max-width: 360px) {
  .rating-buttons,
  .progress-totals {
    grid-template-columns: minmax(0, 1fr);
  }
}
