/* Copyright © 2026 BiblePeep. All rights reserved. */
/* settings.css
   Settings page — restyled to match the site's dark "Live Feed" brand theme
   instead of the earlier plain light form. Builds on app.css's shared
   .btn/.modal styles and tokens.css's color variables.
*/

@import "tokens.css";

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

.settings {
  height: 100vh;
  height: 100dvh;
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(0.85rem, 2.2vh, 1.5rem);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.settings__header {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  margin-bottom: clamp(0.75rem, 2vh, 1.5rem);
  flex-shrink: 0;
}

.settings__header h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0;
  color: var(--text);
}

.header-home-link {
  display: inline-flex;
  align-self: center;
}

.header-home-link img {
  height: 32px;
  width: auto;
  border-radius: 4px;
  display: block;
}

.back-link {
  font-size: 0.9rem;
  color: var(--cyan);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.settings__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: clamp(0.85rem, 2vh, 1.25rem);
  align-items: start;
  flex: 1;
  min-height: 0;
}

.settings__card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: clamp(0.85rem, 2vh, 1.25rem);
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
}

.settings__card h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0 0 clamp(0.5rem, 1.5vh, 1rem);
  color: var(--text);
  flex-shrink: 0;
}

.settings__card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  flex-shrink: 0;
}

.settings__card-header h2 {
  margin: 0;
}

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: clamp(0.5rem, 1.5vh, 1rem);
  flex-shrink: 0;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field input[type="color"] {
  width: 2.6rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  background: var(--bg);
}

.field select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.field-actions {
  margin: clamp(0.5rem, 1.5vh, 1.1rem) 0 clamp(0.4rem, 1vh, 0.9rem);
  flex-shrink: 0;
}

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

.btn--secondary:hover {
  background: #22252d;
}

.btn--primary-small {
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  color: #0a0a0f;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}

.settings__note {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 clamp(0.5rem, 1.5vh, 1rem);
  flex-shrink: 0;
}

.settings__preview-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.5rem;
  flex-shrink: 0;
}

.preview-mount {
  width: 100%;
  max-height: 28vh;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 1;
  min-height: 0;
}

/* ---------- Backup (export / import of uploaded translations) ---------- */

.backup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.btn--small {
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
}

.backup-status {
  margin-bottom: 0.75rem;
}

.backup-status--error {
  color: #e05252;
}

/* ---------- Translation management list ---------- */
/* Scrolls internally past a certain length, rather than growing the whole
   page — the list can grow without bound as translations are uploaded, but
   the page layout shouldn't have to. */

.translation-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}

.translation-list__empty {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.5rem 0;
}

.translation-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-shrink: 0;
}

.translation-list__name {
  font-size: 0.88rem;
  color: var(--text);
}

.translation-list__meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  display: block;
  margin-top: 0.15rem;
}

.translation-list__delete {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}

.translation-list__delete:hover {
  border-color: #e05252;
  color: #e05252;
}

/* Below this height, stop trying to force everything into one screen —
   clamping further would make text/controls illegibly small. Fall back to
   normal scrolling instead, same approach used on the landing page. */
@media (max-height: 620px) {
  html, body {
    height: auto;
  }
  .settings {
    height: auto;
  }
  .settings__card {
    height: auto;
    overflow: visible;
  }
  .translation-list {
    max-height: 240px;
  }
}

/* Phones: the two cards stack, so let the page scroll normally top to bottom
   rather than squeezing both into one screen. */
@media (max-width: 700px) {
  html, body {
    height: auto;
  }
  .settings {
    height: auto;
    padding-left: calc(0.85rem + env(safe-area-inset-left));
    padding-right: calc(0.85rem + env(safe-area-inset-right));
  }
  .settings__grid {
    grid-template-columns: 1fr;
  }
  .settings__card {
    height: auto;
    overflow: visible;
  }
  .preview-mount {
    max-height: none;
  }
  .translation-list {
    max-height: 260px;
  }
}

@media (pointer: coarse) {
  .field select {
    font-size: 16px;
    min-height: 2.75rem;
  }
  .field input[type="color"] {
    width: 3.5rem;
    height: 2.75rem;
  }
  .btn--primary-small,
  .btn--small,
  .translation-list__delete,
  .back-link {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
  }
}
