/* ==== Revision Loop — styles.css ==== */
/* Targets the elements created by app.js. Screen visibility is controlled
   by JS (hidden attribute + inline display), not by :target. */

:root {
  --bg: #FBF8F1;
  --surface: #FFFFFF;
  --border: #E8E0D2;
  --text: #2A2620;
  --muted: #6B6255;
  --accent: #9A5B2C;
  --accent-h: #7C4822;
  --on-accent: #FFFFFF;
  --again-bg: #B3261E;
  --hard-bg: #8A5A00;
  --good-bg: #1F6F43;
  --easy-bg: #1F4E9C;
  --error: #B3261E;
  --radius: 10px;
  --shadow: 0 6px 20px rgba(60, 50, 30, 0.06);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 88% 0%, rgba(232, 224, 210, 0.42), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- nav ---------- */
nav,
header {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

nav button,
header button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

nav button:hover,
header button:hover {
  color: var(--accent-h);
  background: rgba(154, 91, 44, 0.08);
}

/* ---------- screens ---------- */
#screen-decks,
#screen-cards,
#screen-review,
#screen-stats {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  animation: fade-in 200ms ease both;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- headings and text ---------- */
h1, h2, h3 {
  margin: 0 0 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
}

h1 { font-size: 32px; }
h2 { font-size: 22px; }
h3 { font-size: 20px; }

p { margin: 0 0 12px; }

.muted {
  color: var(--muted);
  font-size: 13px;
}

.error {
  margin: 8px 0 0;
  color: var(--error);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 3px 8px rgba(154, 91, 44, 0.18);
}

.btn-primary:hover { background: var(--accent-h); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-h);
}

.btn-danger:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ---------- inputs and textareas ---------- */
input[type="text"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(154, 91, 44, 0.12);
}

textarea {
  resize: vertical;
  min-height: 62px;
  font-family: inherit;
}

/* ---------- decks screen ---------- */
.deck-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.deck-controls .deck-input {
  flex: 1 1 220px;
  min-width: 0;
}

.deck-controls .error {
  flex: 1 1 100%;
}

.deck-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.deck-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.deck-name {
  flex: 1;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-name:hover {
  color: var(--accent);
}

/* ---------- cards screen ---------- */
#cards-heading {
  margin-bottom: 16px;
}

.card-controls {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-controls > button:first-child {
  justify-self: start;
}

.card-controls .error {
  margin: 0;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.card-row {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.card-q {
  margin: 0 0 6px;
  font-weight: 600;
  color: var(--text);
}

.card-a {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.card-row .btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
  margin-right: 6px;
}

/* ---------- review screen ---------- */
.review-card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.review-card > .btn-ghost:first-child {
  margin-bottom: 16px;
}

#review-deck-name {
  margin-bottom: 10px;
}

.review-question {
  margin: 20px 0;
  font-size: 24px;
  line-height: 1.3;
}

.review-answer {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: rgba(154, 91, 44, 0.06);
  border-radius: 6px;
  font-size: 15px;
}

.review-card > .btn-primary {
  min-width: 160px;
}

.rating-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 20px;
}

.rating-btn {
  flex: 1 1 100px;
  min-height: 40px;
  color: var(--on-accent);
  border: 0;
}

.rating-btn.rating-again { background: var(--again-bg); }
.rating-btn.rating-hard  { background: var(--hard-bg); }
.rating-btn.rating-good  { background: var(--good-bg); }
.rating-btn.rating-easy  { background: var(--easy-bg); }

.rating-btn:hover {
  filter: brightness(1.06);
}

/* ---------- stats screen ---------- */
.stats-wrap {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 24px;
  margin: 0 0 24px;
}

.stats-body dt {
  color: var(--muted);
  font-size: 14px;
  align-self: center;
}

.stats-body dd {
  margin: 0;
  text-align: right;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  color: var(--text);
}

.stats-wrap > .btn {
  margin-right: 8px;
}

.import-label {
  position: relative;
  overflow: hidden;
}

.import-label input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ---------- responsive ---------- */
@media (max-width: 600px) {
  #screen-decks,
  #screen-cards,
  #screen-review,
  #screen-stats {
    padding: 24px 16px 48px;
  }

  h1 { font-size: 26px; }
  h2 { font-size: 19px; }
  h3 { font-size: 17px; }

  .deck-row {
    flex-wrap: wrap;
  }

  .deck-name {
    flex: 1 1 100%;
    white-space: normal;
  }

  .review-card,
  .stats-wrap {
    padding: 18px;
  }

  .rating-btn {
    flex: 1 1 45%;
  }

  .stats-body dd {
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}