/* settings.css — The Preferences page (#settings), the sheets it and the tab
   headers open (the choice list, the test-date calendar, the streak and review
   sheets), and drop-down and wide-screen modal behaviour. */

/* ---------- settings page ---------- */
#settings .setinner {
  max-width: 560px;
  margin: 0 auto;
}
/* Save returns you, and the nav sits above this panel, so there is no back
   control here to make room for. */
.settings-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 18px;
}
#settingsTitle,
#settings .setrow > span {
  min-width: 0;
  overflow-wrap: anywhere;
}
#settings .settings-header h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.4px;
  outline: none;
}
/* Preferences reads as a list, not a stack of boxes: a quiet heading with a
   rule under it, then rows that put the name on the left and the control on
   the right, where the eye already is. */
.settings-card {
  padding: 0;
  border: 0;
  background: none;
}
.settings-card + .settings-card {
  margin-top: 34px;
}
#settings .settings-card h2 {
  margin: 0 0 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-1);
  color: var(--ink-2);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -0.3px;
}
.settings-card .setlabel {
  display: block;
  margin: 20px 0 8px;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
}
.settings-card .setlabel:first-of-type {
  margin-top: 16px;
}
.settings-card .setrow:last-child {
  margin-bottom: 0;
}
#settings .installbox {
  margin-top: 14px;
}
#settings .big {
  width: 100%;
  margin: 18px 0 0;
}
@media (min-width: 960px) {
  #settings .settings-header h1 {
    font-size: 34px;
  }
}

.setlabel {
  display: block;
  color: var(--ink-2);
  margin: 14px 0 6px;
}

.setfield {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-align: left;
}

.setfield:hover {
  border-color: var(--brand-line);
}
.setfield #setDateText.is-empty {
  color: var(--ink-2);
  font-weight: 500;
}
.setfield-icon {
  flex: none;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#settings .setpreview {
  width: 100%;
  margin: 12px 0 0;
  min-height: 48px;
  font-size: 15px;
  font-weight: 700;
}

.sethint {
  margin: 10px 0 0;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

/* ---------- the app's own list of choices ---------- */
.choice-panel h2 {
  margin: 0 0 12px;
}
.choice-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.choice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  margin: 0;
  padding: 12px 16px;
  border: 1.5px solid var(--line-2);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
}

.choice-row:hover {
  border-color: var(--brand-line);
}
.choice-row.is-chosen {
  border-color: #19afe8;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 800;
}
.choice-tick {
  flex: none;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #19afe8;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.choice-row.is-chosen .choice-tick {
  opacity: 1;
}
/* Sheet primary: 52px, radius 14px, white label, weight 800. Fill and lip
   stay on local tokens so each sheet does not rewrite the colours. */
.sheet-primary,
#choiceModal .panel .big,
#dateModal .calendar-actions .big,
#streakModal #streakClose,
#dueReviewModal .review-actions .big {
  --sheet-action: #19afe8;
  --sheet-action-lip: #0a97cd;
  min-height: 52px;
  border-radius: 14px;
  background: var(--sheet-action);
  color: #fff;
  box-shadow: 0 4px 0 var(--sheet-action-lip);
  font-weight: 800;
}
#choiceModal .panel .big {
  display: block;
  width: 100%;
  margin: 0;
}

/* ---------- the app's own calendar ---------- */
/* One control on every platform. The grid is always six weeks tall so paging
   through months never resizes the sheet under a thumb that is still moving. */
.calendar-panel {
  padding-bottom: calc(20px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
/* The headline tier, shared with the streak and review sheets below. */
#dateModal .calendar-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.3px;
}

.calendar-grid > div,
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-weekdays {
  margin-bottom: 4px;
}
.calendar-weekdays span {
  padding: 6px 0;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  aspect-ratio: 1;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
}

.calendar-day:hover:not(:disabled) {
  background: var(--panel);
}
/* A day from the neighbouring month is still selectable when it is inside the
   bounds — and it was painted --line-2 either way, which left a tappable October
   date fainter than a genuinely disabled one at opacity .3. Only the disabled
   ones recede now. */
.calendar-day.is-outside {
  color: var(--ink-3);
  font-weight: 600;
}
.calendar-day.is-outside:disabled {
  color: var(--line-2);
}
.calendar-day:disabled {
  opacity: 0.3;
}
/* Today is outlined, the chosen day is filled: two different questions, so
   they must not answer with the same shape. */
.calendar-day.is-today {
  box-shadow: inset 0 0 0 2px var(--brand-line);
}
.calendar-day.is-selected {
  background: #19afe8;
  color: #fff;
  box-shadow: 0 3px 0 #0a97cd;
}
/* The hover wash outranks .is-selected, and turned the chosen day white on
   white under the pointer. It keeps its fill, a shade deeper. */
.calendar-day.is-selected:hover:not(:disabled) {
  background: #12a3dc;
}

.calendar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
#dateModal .calendar-actions .big {
  width: 100%;
  margin: 0;
}
#dateModal .calendar-actions .ghost {
  width: 100%;
  margin: 0;
  min-height: 52px;
}

@media (max-width: 340px) {
  .calendar-day {
    font-size: 15px;
    border-radius: 10px;
  }
  .calendar-grid > div,
  .calendar-weekdays {
    gap: 2px;
  }
}

/* ---------- study streak sheet ---------- */
/* A record, not a picker: the days are read-only, so the calendar is a table
   and the only controls are the month arrows and Close. */
/* Sheets opened from the header's streak and test-day buttons drop down from
   the top of the screen, rather than rising like the others: rounded
   underneath, handle at the bottom, and clear of the status bar. Reduced motion
   still stops the slide (.panel). */
.modal.is-drop-down {
  align-items: flex-start;
}
.modal.is-drop-down .panel {
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  padding: calc(16px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) 16px 10px;
  /* Dropping from the top, it can use nearly the whole screen: the calendar fits
     a small phone without scrolling. */
  max-height: 94dvh;
  animation: sheetdown 0.28s var(--ease);
}
/* The handle follows the content rather than floating at the bottom edge, so
   a sheet taller than a short screen scrolls without it sitting on a button. */
.modal.is-drop-down .panel::before {
  display: none;
}
.modal.is-drop-down .panel::after {
  content: "";
  display: block;
  width: 40px;
  height: 5px;
  margin: 14px auto 0;
  border-radius: 999px;
  background: var(--line-2);
}

/* On a wide screen a sheet is a card in the middle of the window: rounded on
   every corner, no drag handle, never taller than the window. Pinned to an edge,
   the phone sheets read as broken there, and the calendar grew to 70px a day. */
@media (min-width: 720px) {
  .modal,
  .modal.is-drop-down {
    align-items: center;
    padding: 24px;
  }
  .modal .panel,
  .modal.is-drop-down .panel {
    border-radius: var(--r-xl);
    max-height: calc(100dvh - 48px);
    padding: 24px 22px 22px;
    animation: sheetpop 0.2s var(--ease);
  }
  .modal .panel::before,
  .modal.is-drop-down .panel::after {
    display: none;
  }
  #dateModal .panel,
  #streakModal .panel,
  #dueReviewModal .panel {
    max-width: 440px;
  }
  .calendar-day {
    aspect-ratio: auto;
    height: 44px;
  }
}
@keyframes sheetpop {
  from {
    transform: scale(0.97);
    opacity: 0;
  }
}
@keyframes sheetdown {
  from {
    transform: translateY(-18%);
  }
}
.streak-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
}
#streakModal .streak-head h2,
#dueReviewModal .streak-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.2px;
  text-transform: uppercase;
}
.streak-head p {
  margin: 2px 0 0;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
}
.streak-calendar {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 4px;
}
.streak-calendar th {
  padding: 4px 0;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}
.streak-calendar td {
  padding: 0;
  text-align: center;
}
.streak-day {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 40px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.streak-day > span[aria-hidden] {
  display: grid;
  place-items: center;
}
.streak-day.is-studied {
  background: var(--amber-soft);
}
.streak-day.is-studied svg {
  width: 22px;
  height: 22px;
}
.streak-day.is-today {
  box-shadow: inset 0 0 0 2px var(--brand-line);
}
.streak-day.is-future {
  opacity: 0.45;
}
#streakModal #streakClose {
  display: block;
  width: 100%;
  margin: 16px 0 0;
}
@media (max-width: 340px) {
  .streak-calendar {
    border-spacing: 2px;
  }
  .streak-day {
    font-size: 13px;
  }
}

/* ---------- review sheet ---------- */
/* Same head as the streak: what the count means, then the one thing to do about it. */
.review-actions {
  display: grid;
  gap: 10px;
}
#dueReviewModal .review-actions .big {
  display: block;
  width: 100%;
  margin: 0;
}
#dueReviewModal .review-actions .ghost {
  width: 100%;
  margin: 0;
  min-height: 52px;
}

.setrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  min-height: 56px;
  font-weight: 800;
}

/* A switch rather than a tick box: it reads as a thing that is on, which is
   what these settings are, and it gives the row a right-hand edge to align to. */
.setrow input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 52px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: var(--line-2);
  cursor: pointer;
  transition: background 0.18s var(--ease);
}

.setrow input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px #0000002e;
  transition: transform 0.18s var(--ease);
}

.setrow input[type="checkbox"]:checked {
  background: var(--brand);
}

.setrow input[type="checkbox"]:checked::after {
  transform: translateX(22px);
}

.setrow input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--brand-ink);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .setrow input[type="checkbox"],
  .setrow input[type="checkbox"]::after {
    transition: none;
  }
}

.installbox {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 14px 16px;
  border: 1.5px solid var(--brand-line);
  border-radius: var(--r);
  background: var(--brand-soft);
}

.installbox h3 {
  margin: 0 0 2px;
  font-size: 1rem;
  line-height: 1.4;
}

.installbox p {
  margin: 0;
  color: var(--brand-ink);
  font-weight: 600;
  line-height: 1.4;
}
