/* Estilos de StudyGate (NFR-008: sin desplazamiento horizontal a 375 px; NFR-009: WCAG 2.2 AA).
   Sin estilos en línea: la CSP solo permite style-src 'self' (D-16). */
:root {
  --bg: #ffffff;
  --surface: #f4f5f7;
  --text: #1b1d21;
  --muted: #4a4f57;
  --border: #8a9099;
  --link: #0b4fb3;
  --primary: #0b4fb3;
  --primary-text: #ffffff;
  --focus: #b34700;
  --ok-bg: #e3f3e7;
  --ok-text: #135f2a;
  --warn-bg: #fff3d6;
  --warn-text: #6b4500;
  --error-bg: #fde7e7;
  --error-text: #8f1515;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #23262b;
    --text: #eceef1;
    --muted: #b9bec6;
    --border: #8a9099;
    --link: #8fb8ff;
    --primary: #8fb8ff;
    --primary-text: #0d1117;
    --focus: #ffb36b;
    --ok-bg: #133a22;
    --ok-text: #b6ecc4;
    --warn-bg: #3d2f0b;
    --warn-text: #ffe2a3;
    --error-bg: #431818;
    --error-text: #ffc4c4;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

a { color: var(--link); text-underline-offset: 0.15em; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

[hidden] { display: none !important; }

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

.skip-link {
  position: absolute; left: 1rem; top: -4rem;
  background: var(--bg); color: var(--link);
  padding: 0.5rem 0.75rem; border: 2px solid var(--link);
  z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.breadcrumb { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; align-items: center; min-width: 0; }
.breadcrumb a, .breadcrumb [aria-current] { font-weight: 600; }
.breadcrumb .sep { color: var(--muted); }

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
}
main:focus { outline: none; }

h1 { font-size: 1.75rem; line-height: 1.2; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.25rem 0 0.5rem; }
h3 { font-size: 1.0625rem; margin: 1rem 0 0.5rem; }

.status:empty { display: none; }
.status { margin: 0 0 1rem; color: var(--muted); }

.button, .link-button {
  font: inherit;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}
.button {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1rem;
  border: 2px solid var(--primary);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.button.primary { background: var(--primary); color: var(--primary-text); }
.button:disabled { opacity: 0.6; cursor: not-allowed; }
.link-button {
  background: none; border: none; padding: 0.25rem 0;
  color: var(--link); text-decoration: underline;
}

.notice { padding: 0.75rem 1rem; border-radius: 0.5rem; background: var(--surface); margin: 0 0 1rem; }
.notice-warn { background: var(--warn-bg); color: var(--warn-text); font-weight: 600; }
.notice-error { background: var(--error-bg); color: var(--error-text); font-weight: 600; }

.hint { color: var(--muted); }

.overview { border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.5rem 1rem 0.75rem; margin-bottom: 1rem; }
.overview-title { margin-top: 0.5rem; }
.overview-list { list-style: none; margin: 0; padding: 0; }
.overview-list li { display: flex; flex-wrap: wrap; gap: 0 0.75rem; padding: 0.375rem 0; border-top: 1px solid var(--surface); }
.overview-list li:first-child { border-top: none; }
.overview-list a { font-weight: 600; }
.glance { color: var(--muted); }

.part { border: 1px solid var(--border); border-radius: 0.75rem; margin: 0 0 0.75rem; }
.part-heading { margin: 0; font-size: 1.125rem; }
.part-toggle {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 48px;
  padding: 0.75rem 1rem;
  background: none; border: none; border-radius: 0.75rem;
  color: var(--text); font: inherit; font-weight: 700; text-align: left;
  cursor: pointer;
}
.part-arrow {
  flex: none;
  width: 0.75rem; height: 0.75rem;
  border-right: 3px solid currentColor; border-bottom: 3px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.part-toggle[aria-expanded="true"] .part-arrow { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .part-arrow { transition: none; } }
.part-body { padding: 0 1rem 1rem; }
.back { margin: 1rem 0 0; }

.big { font-size: 1.5rem; font-weight: 700; margin: 0.25rem 0; }
.remaining { margin: 0.25rem 0 0.75rem; }
progress { width: 100%; height: 1rem; accent-color: var(--primary); }

.pill { display: inline-block; padding: 0.375rem 0.75rem; border-radius: 999px; font-weight: 700; margin: 0.25rem 0 0.5rem; }
.pill-closed { background: var(--warn-bg); color: var(--warn-text); }
.pill-open, .pill-ok { background: var(--ok-bg); color: var(--ok-text); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; padding: 0; margin: 0 0 0.5rem; }
.mark { font-weight: 700; }
.mark-met { color: var(--ok-text); }
.mark-unmet { color: var(--error-text); }

.week-header, .days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.25rem;
}
.week-header { color: var(--muted); font-size: 0.875rem; text-align: center; margin-bottom: 0.25rem; }
.days { list-style: none; padding: 0; margin: 0; }
.day {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 0.25rem 0;
  border-radius: 0.375rem;
  text-decoration: none;
  border: 1px solid var(--border);
}
.day-met { background: var(--ok-bg); color: var(--ok-text); }
.day-unmet { background: var(--error-bg); color: var(--error-text); }
.day-num { font-weight: 700; line-height: 1.1; }
.day-mark { line-height: 1.1; }

.sections ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.75rem; }

.facts { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 0.5rem 1rem; }
.facts dt { font-weight: 700; }
.facts dd { margin: 0; }

.field { margin: 0.75rem 0 1rem; }
.field label { display: block; font-weight: 700; margin-bottom: 0.25rem; }
input[type="text"] {
  font: inherit; width: 8rem; max-width: 100%;
  min-height: 44px; padding: 0.5rem 0.75rem;
  border: 2px solid var(--border); border-radius: 0.375rem;
  background: var(--bg); color: var(--text);
}
input[aria-invalid="true"] { border-color: var(--error-text); }
.field-error { color: var(--error-text); font-weight: 700; margin: 0.25rem 0; }
fieldset { border: none; padding: 0; margin: 0.75rem 0 1rem; min-width: 0; }
legend { font-weight: 700; padding: 0; }
.checks { display: grid; gap: 0.25rem; }
.check { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; }
.check input { width: 1.375rem; height: 1.375rem; accent-color: var(--primary); }
.check label { cursor: pointer; flex: 1; }

.error-summary {
  border: 3px solid var(--error-text);
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  margin: 0 0 1rem;
}
.error-summary h2 { margin-top: 0.25rem; color: var(--error-text); }

.steps { padding-left: 1.5rem; }
.steps li { margin-bottom: 0.5rem; }
