/* ═══════════════════════════════════════════════════════════
   NetWord — styles.css
   Structure and component rules only. No colors or fonts.
   All design tokens live in shared/css/theme.css — edit that to rebrand.
═══════════════════════════════════════════════════════════ */

/* ── NWM variable mapping ────────────────────────────────── */
/* These map to reading containers via surface.css too, but are
   also set here so nwm-* elements and #scripture-popup work
   correctly outside .layer-pane-content (e.g. fixed overlays). */
:root {
  --nwm-size:    1rem;
  --nwm-text:    var(--text-2);
  --nwm-muted:   var(--text-2);
  --nwm-accent:  var(--accent);
  --nwm-brand:   var(--accent);
  --nwm-border:  var(--border);
  --nwm-surface: var(--bg-card);
  --nwm-shadow:  var(--shadow-card);
  --nwm-focus:   var(--accent);
}

/* ── Layout constants (not part of the theme) ───────────── */
:root {
  --topbar-h:        42px;
  --bar-h:           36px;  /* reference bar, text panel footer, study panel header, study tabs */

  --btn-size:        28px;  /* buttons inside bars (chips, study tabs) */
  --btn-icon:        16px;  /* icons inside bar buttons */

  --topbar-btn-size: 32px;  /* topbar icon buttons — independent so you can size separately */
  --topbar-btn-icon: 18px;
}

/* ───────────────────────────────────────
   RESET & BASE
─────────────────────────────────────── */

/* Enforce the HTML hidden attribute against any display overrides */
[hidden] { display: none !important; }

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

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

body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

select, input {
  font-family: inherit;
}

details > summary {
  list-style: none;
  cursor: pointer;
}
details > summary::-webkit-details-marker { display: none; }

/* ───────────────────────────────────────
   TOPBAR
─────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 2px 0 0 var(--navy), var(--shadow-card);
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 12px;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.logo {
  height: 26px;
  width: auto;
}

.logo--dark { display: none; }

@media (prefers-color-scheme: dark) {
  .logo--light { display: none; }
  .logo--dark  { display: block; }
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--topbar-btn-size);
  height: var(--topbar-btn-size);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}

.icon-btn img {
  width: var(--topbar-btn-icon);
  height: var(--topbar-btn-icon);
  opacity: 0.7;
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn:hover img,
.icon-btn:focus-visible img {
  opacity: 1;
}

/* ───────────────────────────────────────
   MAIN LAYOUT
─────────────────────────────────────── */
/* Phone: flat layout, no card chrome */
.main-wrap {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  padding: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0;
  height: 100%;
}

/* Two columns: any screen wide enough (includes landscape phones) */
@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
  }
}

/* Card chrome + spacing: wide AND tall enough (tablet+, not landscape phone) */
@media (min-width: 640px) and (min-height: 480px) {
  .main-wrap {
    padding: 8px;
  }
  .card-grid {
    gap: 8px;
  }
}

/* Desktop: full spacing */
@media (min-width: 1024px) and (min-height: 480px) {
  .main-wrap {
    padding: 10px;
  }
  .card-grid {
    gap: 10px;
  }
}

/* ───────────────────────────────────────
   CARD
─────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Divider between stacked panels on portrait phone only */
@media (max-width: 639px) {
  .card + .card {
    border-top: 1px solid var(--border);
  }
}

@media (min-width: 640px) and (min-height: 480px) {
  .card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
  }
}

@media (min-width: 1024px) and (min-height: 480px) {
  .card {
    border-radius: var(--radius);
  }
}

/* ───────────────────────────────────────
   TEXT PANEL
─────────────────────────────────────── */
.text-panel-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.reference-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--bar-h);
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.reference-bar__nav {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.reference-bar__address {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 4px;
}

.chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--btn-size);
  height: var(--btn-size);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  flex-shrink: 0;
  transition: background 0.12s;
}

.chip img {
  width: var(--btn-icon);
  height: var(--btn-icon);
  opacity: 0.55;
}

.chip:hover {
  background: var(--accent-soft);
}

.chip:hover img {
  opacity: 1;
}

.verse-input {
  flex: 1;
  min-width: 0;
  height: var(--btn-size);
  padding: 0 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.verse-input::placeholder {
  color: var(--text-3);
}

.verse-input:focus {
  border-color: var(--border);
  box-shadow: none;
  outline: none;
}

/* Verse display area → verse-panel.css */

.text-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--bar-h);
  padding: 0 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  container-type: inline-size;
}

.text-panel-footer__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chapter-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font-body);
}

.chapter-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.chapter-arrow {
  font-size: 12px;
  color: var(--text-3);
  padding: 3px 5px;
  border-radius: var(--radius-xs);
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}

.chapter-arrow:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

@media (min-width: 640px) {
  .chapter-arrow { font-size: 14px; padding: 4px 6px; }
}

.translation-label {
  font-size: 11px;
  color: var(--text-3);
  text-align: right;
}

.label-full { display: none; }
.label-abbr { display: block; }

@container (min-width: 400px) {
  .label-full { display: block; }
  .label-abbr { display: none; }
}

@media (min-width: 640px) {
  #textPanel {
    border-right: 1px solid var(--border);
  }
}

/* ───────────────────────────────────────
   STUDY PANEL
─────────────────────────────────────── */
.study-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--bar-h);
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.study-panel-header img {
  width: 16px;
  height: 16px;
  opacity: 0.75;
  flex-shrink: 0;
}

.study-panel-header span {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
}


.study-panel-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.layer-pane {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.layer-pane--active {
  display: flex;
}

.layer-pane-content {
  /* font, color, background, padding — owned by shared/css/surface.css */
  flex: 1;
  display: flex;
  flex-direction: column;
}

.layer-pane::-webkit-scrollbar,
.layer-pane-content::-webkit-scrollbar { width: 4px; }
.layer-pane::-webkit-scrollbar-track,
.layer-pane-content::-webkit-scrollbar-track { background: transparent; }
.layer-pane::-webkit-scrollbar-thumb,
.layer-pane-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}


/* ───────────────────────────────────────
   STUDY TABS
─────────────────────────────────────── */
.study-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: var(--bar-h);
  border-top: 1px solid var(--border);
  padding: 0 6px;
  flex-shrink: 0;
  background: var(--bg-card);
}

.study-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--btn-size);
  height: var(--btn-size);
  border-radius: var(--radius-xs);
  transition: background 0.12s;
}

.study-tab img {
  width: var(--btn-icon);
  height: var(--btn-icon);
  opacity: 0.45;
  transition: opacity 0.12s;
}

.study-tab:hover img {
  opacity: 0.75;
}

.study-tab--active img {
  opacity: 1;
}

.study-tab--active {
  background: var(--accent-soft);
}

/* ───────────────────────────────────────
   ACCESSIBILITY
─────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ───────────────────────────────────────
   TABLET — tighter inner spacing
─────────────────────────────────────── */
@media (min-width: 640px) and (max-width: 1023px) and (min-height: 480px) {
  .layer-pane-content  { padding: 10px; }
}

/* ───────────────────────────────────────
   SAFE AREA — notched phones
─────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .topbar {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }
  .main-wrap {
    top: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}

/* ───────────────────────────────────────
   STUDY NOTES
─────────────────────────────────────── */
.notes-empty {
  font-size: 13px;
  color: var(--text-3);
  font-style: italic;
}

/* ───────────────────────────────────────
   LOCKED LAYER PROMPT
─────────────────────────────────────── */
.layer-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 32px 20px;
  gap: 12px;
  text-align: center;
}

.layer-locked__logo {
  width: 120px;
  margin-bottom: 4px;
}

.layer-locked__logo--dark  { display: none; }
@media (prefers-color-scheme: dark) {
  .layer-locked__logo--light { display: none; }
  .layer-locked__logo--dark  { display: block; }
}

.layer-locked__thanks {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

.layer-locked__message {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.5;
}

.layer-locked__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 240px;
}

.layer-locked__btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.layer-locked__btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.layer-locked__btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.layer-locked__btn--primary:hover {
  background: var(--accent-text);
  border-color: var(--accent-text);
  color: #fff;
}

/* ───────────────────────────────────────
   GET ACCESS MODAL
─────────────────────────────────────── */
.get-access-intro {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 16px;
  line-height: 1.6;
}

.distributor-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.distributor-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-decoration: none;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
}

.distributor-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.distributor-flag {
  font-size: 24px;
  flex-shrink: 0;
}

.distributor-country {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.distributor-arrow {
  color: var(--text-3);
  font-size: 16px;
}