/* ===========================================================================
   Spotiny · settings.css
   ----------------------------------------------------------------------------
   Settings modal, sleep-timer modal, speed picker modal, install banner,
   update banner, skip-link, switch, slider, theme cards, accent cards,
   keyboard-shortcut list, storage usage.
   =========================================================================== */

/* ---- Generic modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal.is-open {
  display: flex;
  animation: modal-fade-in 0.2s var(--ease-out);
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

.modal__sheet {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 92%;
  max-width: 600px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-slide-up 0.28s var(--ease-spring);
}
.modal__sheet--sm      { max-width: 420px; }
.modal__sheet--settings {
  background: var(--bg-elevated);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  max-height: 85vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  max-width: var(--app-max-w);
  width: 100%;
  margin: 0 auto;
}

@keyframes modal-slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal__header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal__title {
  font-size: var(--fs-18);
  font-weight: 800;
  letter-spacing: -0.01em;
  flex: 1;
  margin: 0;
}

.modal__body {
  padding: var(--sp-4) var(--sp-5);
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.modal__body::-webkit-scrollbar { width: 8px; }
.modal__body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

/* ---- Settings tabs ---- */
.settings-tabs {
  display: flex;
  gap: var(--sp-1);
  padding-bottom: var(--sp-3);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.settings-tab {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: var(--fs-14);
  font-weight: 500;
  border-radius: var(--r-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-1), color var(--dur-1);
}
.settings-tab svg { width: 16px; height: 16px; }
.settings-tab:hover  { background: var(--surface-2); color: var(--text); }
.settings-tab:active { transform: scale(0.97); }
.settings-tab.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.settings-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.settings-section-label {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: var(--sp-5) 0 var(--sp-2);
}
.settings-section-label:first-child { margin-top: 0; }

.settings-list { display: flex; flex-direction: column; gap: var(--sp-3); }

/* ---- Grid for theme/accent/speed cards ---- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--sp-2);
}
.settings-grid--accent {
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
}
.settings-grid--speed {
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
}

/* ---- Theme card ---- */
.theme-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  transition: border-color var(--dur-1), transform var(--dur-1), background var(--dur-1);
}
.theme-card:hover  { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-1px); }
.theme-card:active { transform: translateY(0) scale(0.98); }
.theme-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-card.is-active { border-color: var(--accent); background: var(--accent-softer); }

.theme-card__swatch {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--bg) 0%, var(--surface-2) 100%);
}
.theme-card__swatch--dark     { background: linear-gradient(135deg, #060608 0%, #1a1a22 100%); }
.theme-card__swatch--light    { background: linear-gradient(135deg, #f7f7fa 0%, #ffffff 100%); color: #000; }
.theme-card__swatch--black    { background: linear-gradient(135deg, #000 0%, #1a1a1a 100%); }
.theme-card__swatch--midnight { background: linear-gradient(135deg, #0a0e1a 0%, #232c52 100%); }
.theme-card__swatch--sunset   { background: linear-gradient(135deg, #1a0d10 0%, #5d3144 100%); }

.theme-card__label { font-size: var(--fs-13); font-weight: 500; }
.theme-card__check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px; height: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
}
.theme-card__check svg { width: 12px; height: 12px; }

/* ---- Accent card ---- */
.accent-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  transition: border-color var(--dur-1), transform var(--dur-1);
}
.accent-card:hover  { border-color: var(--border-strong); transform: translateY(-1px); }
.accent-card:active { transform: translateY(0) scale(0.96); }
.accent-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.accent-card.is-active { border-color: var(--accent); }
.accent-card__swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.1);
}
.accent-card__label { font-size: var(--fs-12); text-align: center; }
.accent-card__check {
  position: absolute;
  top: 6px; right: 6px;
  width: 18px; height: 18px;
  background: #fff;
  color: #000;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
}
.accent-card__check svg { width: 10px; height: 10px; }

/* ---- Speed card ---- */
.speed-card {
  padding: var(--sp-2) var(--sp-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  font-size: var(--fs-14);
  font-weight: 600;
  text-align: center;
  transition: border-color var(--dur-1), transform var(--dur-1), background var(--dur-1);
}
.speed-card:hover  { border-color: var(--border-strong); background: var(--surface-2); }
.speed-card:active { transform: scale(0.96); }
.speed-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.speed-card.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.speed-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: var(--sp-2);
}

/* ---- Toggle row ---- */
.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
}
.toggle-row__text { flex: 1; }
.toggle-row__label { font-size: var(--fs-14); font-weight: 500; }
.toggle-row__desc  { font-size: var(--fs-12); color: var(--muted); margin-top: 2px; }

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch__track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--dur-2);
}
.switch__track::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--dur-2) var(--ease-spring);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::before { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Slider row ---- */
.slider-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
}
.slider-row__input {
  flex: 1;
  height: 4px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-size: 50% 100%;
  cursor: pointer;
}
.slider-row__input::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--dur-1);
  box-shadow: 0 1px 4px var(--accent-glow);
}
.slider-row__input::-webkit-slider-thumb:hover  { transform: scale(1.2); }
.slider-row__input::-webkit-slider-thumb:active { transform: scale(1.1); }
.slider-row__input::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--accent);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.slider-row__input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.slider-row__value {
  min-width: 48px;
  text-align: right;
  font-size: var(--fs-13);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

/* ---- Stat row ---- */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-2) 0;
  font-size: var(--fs-14);
}
.stat-row__label { color: var(--text-2); }
.stat-row__value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Action row ---- */
.action-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
}
.action-row__icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: var(--r-md);
  color: var(--muted);
  flex-shrink: 0;
}
.action-row__icon svg { width: 18px; height: 18px; }
.action-row__text { flex: 1; }
.action-row__label { font-size: var(--fs-14); font-weight: 500; }
.action-row__desc  { font-size: var(--fs-12); color: var(--muted); margin-top: 2px; }

/* ---- Generic button ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-14);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-1), transform var(--dur-1), border-color var(--dur-1);
}
.btn:hover  { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--danger { color: var(--danger); border-color: var(--border); }
.btn--danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }
.settings-btn { width: 100%; margin-top: var(--sp-2); }

/* ---- Storage usage ---- */
.storage-usage {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  font-size: var(--fs-14);
  color: var(--text-2);
}
.storage-usage strong { color: var(--text); }

/* ---- About block ---- */
.about-block {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  font-size: var(--fs-14);
  line-height: 1.6;
  color: var(--text-2);
}
.about-block p { margin: 0 0 var(--sp-2); }
.about-block p:last-child { margin-bottom: 0; }

/* ---- Keyboard shortcuts list ---- */
.kbd-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.kbd-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-13);
}
.kbd-row kbd {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  padding: 2px 6px;
  font-size: var(--fs-12);
  color: var(--text);
  min-width: 90px;
  text-align: center;
}
.kbd-row span { color: var(--text-2); }

/* ---- Sleep timer ---- */
.sleep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.sleep-preset {
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  text-align: center;
  transition: border-color var(--dur-1), transform var(--dur-1), background var(--dur-1);
}
.sleep-preset:hover  { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-1px); }
.sleep-preset:active { transform: scale(0.96); }
.sleep-preset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sleep-preset__num  { font-size: var(--fs-24); font-weight: 700; }
.sleep-preset__unit { font-size: var(--fs-12); color: var(--muted); }

.sleep-custom {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
}
.sleep-custom__label { font-size: var(--fs-13); color: var(--text-2); margin-bottom: var(--sp-2); }
.sleep-custom__row { display: flex; gap: var(--sp-2); }
.sleep-custom__input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-14);
}
.sleep-custom__input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.sleep-status {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--accent-soft);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
}
.sleep-status__icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: var(--accent);
}
.sleep-status__icon svg { width: 24px; height: 24px; }
.sleep-status__text { font-size: var(--fs-16); }
.sleep-status__text strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.sleep-cancel-btn { width: 100%; }

/* ---- Install banner ---- */
.install-banner {
  position: fixed;
  bottom: calc(var(--mini-h) + var(--sp-3));
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: 92vw;
  animation: banner-slide-up 0.3s var(--ease-spring);
}
@keyframes banner-slide-up {
  from { transform: translate(-50%, 100%); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}
.install-banner__icon {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.install-banner__icon svg { width: 20px; height: 20px; }
.install-banner__body { flex: 1; min-width: 0; }
.install-banner__title { font-size: var(--fs-14); font-weight: 600; }
.install-banner__sub   { font-size: var(--fs-12); color: var(--muted); margin-top: 2px; }
.install-banner__btn {
  padding: var(--sp-2) var(--sp-3);
  border: 0;
  border-radius: var(--r-pill);
  font: inherit;
  font-size: var(--fs-13);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-1), transform var(--dur-1);
}
.install-banner__btn--later {
  background: transparent;
  color: var(--muted);
}
.install-banner__btn--later:hover { color: var(--text); }
.install-banner__btn--install {
  background: var(--accent);
  color: #fff;
}
.install-banner__btn--install:hover { background: var(--accent-strong); }
.install-banner__btn:active { transform: scale(0.96); }

/* ---- Update banner ---- */
.update-banner {
  position: fixed;
  bottom: var(--sp-3);
  left: 50%;
  transform: translateX(-50%);
  z-index: 850;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-accent);
  max-width: 92vw;
  font-size: var(--fs-13);
  animation: banner-slide-up 0.3s var(--ease-spring);
}
.update-banner__text { font-weight: 500; }
.update-banner__btn {
  padding: 4px 12px;
  background: rgba(255,255,255,0.2);
  border: 0;
  border-radius: var(--r-pill);
  color: #fff;
  font: inherit;
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-1);
}
.update-banner__btn:hover { background: rgba(255,255,255,0.3); }
.update-banner__btn--later { background: transparent; }
.update-banner__btn--later:hover { background: rgba(255,255,255,0.15); }

/* ---- Skip link ---- */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--sp-3);
  z-index: 9999;
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-14);
  font-weight: 600;
  border-radius: var(--r-md);
  text-decoration: none;
  transition: top var(--dur-2);
}
.skip-link:focus {
  top: var(--sp-3);
}

/* ---- Screen-reader-only ---- */
.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;
}
