/* ═══════════════════════════════════════════
   CIFRAS — Style Sheet
   OLED Dark · Orange Accents · Worship Mode
═══════════════════════════════════════════ */

/* ── Variables ─────────────────────────────── */
:root {
  --bg:            #0a0a0a;
  --bg-elevated:   #111111;
  --bg-card:       #161616;
  --bg-input:      #1a1a1a;
  --border:        rgba(255,255,255,0.07);
  --border-subtle: rgba(255,255,255,0.04);

  --accent:        #e8650a;
  --accent-dim:    rgba(232,101,10,0.15);
  --accent-glow:   rgba(232,101,10,0.35);

  --text-primary:  #f0f0f0;
  --text-secondary:#888888;
  --text-dim:      #555555;

  --font-ui:       'SF Pro Display', -apple-system, 'Helvetica Neue', Helvetica, sans-serif;
  --font-lyric:    Arial, 'Helvetica Neue', Helvetica, sans-serif;
  --font-chord:    'SF Mono', 'Fira Mono', 'Courier New', monospace;

  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     18px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* ── Reset ──────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Screen System ──────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  overflow: hidden;
  /* iOS safe height */
  height: 100%;
  max-height: -webkit-fill-available;
}

.screen.active {
  transform: translateX(0);
}

.screen.slide-out {
  transform: translateX(-30%);
}

/* ── MAIN SCREEN ────────────────────────────── */

/* Header */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 16px) 20px 12px;
  flex-shrink: 0;
}

.app-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-primary);
}

/* Search */
.search-wrap {
  position: relative;
  margin: 0 16px 12px;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-dim);
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px 10px 38px;
  font-size: 15px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

#search-input::placeholder {
  color: var(--text-dim);
}

#search-input:focus {
  border-color: var(--accent);
  background: var(--bg-elevated);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin: 0 16px 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 4px;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 8px 0;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 3px);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab.active {
  background: var(--bg-card);
  color: var(--accent);
}

/* Tab Panels */
.tab-panel {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.tab-panel.active {
  display: flex;
}

/* Song List */
.song-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  list-style: none;
  padding: 0 0 calc(var(--safe-bottom) + 16px);
}

.song-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.song-list li:active {
  background: var(--bg-elevated);
}

.song-title-text {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Heart button */
.heart-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.heart-btn.active {
  color: var(--accent);
}

.heart-btn:active {
  transform: scale(0.85);
}

/* Drag handle */
.drag-handle {
  color: var(--text-dim);
  cursor: grab;
  padding: 4px;
  flex-shrink: 0;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

/* Favorites actions */
.fav-actions {
  padding: 10px 16px 4px;
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost.danger:active {
  color: #ff4444;
  border-color: #ff4444;
}

/* Empty state */
.empty-msg {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
  padding: 40px 32px;
  white-space: pre-line;
}

.hidden {
  display: none !important;
}

/* Offline badge */
.offline-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  border-radius: 20px;
  padding: 3px 9px;
}

/* ── SONG SCREEN ────────────────────────────── */

/* Top bar */
.song-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) calc(var(--safe-right) + 12px) 10px calc(var(--safe-left) + 12px);
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 10;
  transition: opacity 0.3s;
}

.song-topbar.hidden-bar {
  opacity: 0;
  pointer-events: none;
}

.song-topbar-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Brightness panel */
.brightness-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.brightness-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}

.brightness-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px var(--accent-glow);
}

.brightness-icon-low,
.brightness-icon-high {
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Song content area */
.song-content-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 10px calc(var(--safe-right) + 12px) calc(var(--safe-bottom) + 6px) calc(var(--safe-left) + 12px);
  min-height: 0; /* critical for flex children to shrink on iOS */
}

.song-content {
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  font-family: var(--font-lyric);
  white-space: pre-wrap;
  line-height: 1.45;
  transform-origin: top left;
  display: block;
  /* Allow pinch-zoom on iPad without triggering page-level zoom */
  touch-action: pan-x pan-y pinch-zoom;
}

/* Song title inside content */
.song-content .song-main-title {
  font-size: 1.15em;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5em;
  letter-spacing: 0.03em;
  font-family: var(--font-ui);
  display: block;
  white-space: pre-wrap;
}

/* Lyric lines */
.line-lyric {
  display: block;
  color: var(--text-primary);
  font-family: var(--font-lyric);
  white-space: pre-wrap;
}

/* Chord lines */
.line-chord {
  display: block;
  color: var(--accent);
  font-family: var(--font-chord);
  font-weight: 600;
  white-space: pre;
}

/* Empty lines */
.line-empty {
  display: block;
  height: 0.55em;
}

/* Section headers (e.g. [Refrão]) */
.line-section {
  display: block;
  color: var(--text-dim);
  font-size: 0.82em;
  font-family: var(--font-ui);
  font-style: italic;
  letter-spacing: 0.05em;
  white-space: pre-wrap;
}

/* Brightness overlay */
.brightness-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  transition: opacity 0.1s;
}

/* ── Drag & Drop ────────────────────────────── */
.song-list li.dragging {
  opacity: 0.4;
  background: var(--accent-dim);
}

.song-list li.drag-over {
  border-top: 2px solid var(--accent);
}

/* ── Scrollbar (minimal, webkit) ────────────── */
.song-list::-webkit-scrollbar {
  width: 3px;
}

.song-list::-webkit-scrollbar-track {
  background: transparent;
}

.song-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── Loading state ──────────────────────────── */
#song-list.loading::after,
#fav-list.loading::after {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  margin: 40px auto;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Tap states (iOS feel) ───────────────────── */
@media (hover: none) {
  .tab:hover { background: transparent; }
  .icon-btn:hover { background: transparent; }
}

/* ═══════════════════════════════════════════
   iPAD PORTRAIT OVERRIDES
   min-width 768px covers all iPad models
═══════════════════════════════════════════ */
@media (min-width: 768px) {

  /* Main screen: larger text, more breathing room */
  .app-title {
    font-size: 34px;
    letter-spacing: 0.14em;
  }

  #search-input {
    font-size: 17px;
    padding: 12px 14px 12px 42px;
    border-radius: var(--radius-lg);
  }

  .tab {
    font-size: 14px;
    padding: 10px 0;
  }

  .song-list li {
    padding: 16px 24px;
  }

  .song-title-text {
    font-size: 17px;
  }

  /* Song screen: maximise content area */
  .song-content-wrap {
    padding: 14px calc(var(--safe-right) + 20px) calc(var(--safe-bottom) + 10px) calc(var(--safe-left) + 20px);
  }

  /* Chord and lyric line-height: slightly more open on iPad for readability */
  .song-content {
    line-height: 1.5;
  }

  /* Topbar: slightly taller touch targets */
  .song-topbar {
    padding-top: calc(var(--safe-top) + 14px);
    padding-bottom: 14px;
  }

  .song-topbar-title {
    font-size: 16px;
  }

  .icon-btn {
    padding: 8px;
  }
}

