/* ============================================================
   Sicily Travel Phrases — styles.css (mobile-first)
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #D4603A;
  --primary-dark: #B84E2C;
  --primary-light: #F5A66E;
  --primary-bg: #FEF1EB;
  --bg: #F9F5F1;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-secondary: #6B7280;
  --text-light: #9CA3AF;
  --border: #E8E0D8;
  --success: #059669;
  --success-bg: #ECFDF5;
  --emergency: #DC2626;
  --emergency-bg: #FEF2F2;
  --essential-bg: #FFF7ED;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --nav-height: 64px;
  --header-height: 56px;
  --max-width: 480px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

body.overlay-open { overflow: hidden; }

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

a { text-decoration: none; color: inherit; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  height: var(--header-height);
}

.header-back {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px 4px 0;
  line-height: 1;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ---------- Bottom Nav ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--nav-height);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-secondary);
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab.active { color: var(--primary); }
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-weight: 500; }

/* ---------- Page content ---------- */
.page-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
  overflow-y: auto;
}

/* ---------- Scenario Grid ---------- */
.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.scenario-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.scenario-card:active {
  transform: scale(0.97);
  box-shadow: var(--shadow-lg);
}

.scenario-icon { font-size: 32px; line-height: 1; }

.scenario-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.scenario-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* ---------- Scenario intro ---------- */
.scenario-intro {
  text-align: center;
  padding: 16px 0;
}
.scenario-intro-icon { font-size: 48px; }
.scenario-intro-desc {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ---------- Section title ---------- */
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: var(--text);
}

/* ---------- Script List ---------- */
.scripts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.script-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s;
}

.script-item:active { transform: scale(0.98); }

.script-title {
  font-size: 15px;
  font-weight: 600;
}

.script-count {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.script-arrow {
  font-size: 22px;
  color: var(--text-light);
  font-weight: 300;
}

/* ---------- Phrase Card ---------- */
.phrase-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.phrase-card.essential { border-left: 4px solid var(--primary); }
.phrase-card.emergency { border-left: 4px solid var(--emergency); background: var(--emergency-bg); }
.phrase-card.compact { padding: 12px; }

.phrase-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-essential { background: var(--essential-bg); color: var(--primary-dark); }
.badge-emergency { background: var(--emergency-bg); color: var(--emergency); }
.badge-step { background: var(--primary-bg); color: var(--primary-dark); }

.phrase-it {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
}

.compact .phrase-it { font-size: 17px; }

.phrase-meaning {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-style: italic;
}

.phrase-tip {
  font-size: 13px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
  line-height: 1.4;
  color: var(--text);
}

.tip-label {
  font-weight: 700;
  color: var(--primary-dark);
}

/* ---------- Phrase Actions ---------- */
.phrase-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font);
}

.btn:active { transform: scale(0.95); }

.btn-play {
  background: var(--primary);
  color: #fff;
}
.btn-play:active { background: var(--primary-dark); }

.btn-slow {
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.btn-stop {
  background: #F3F4F6;
  color: var(--text-secondary);
}

.btn-show {
  background: #EEF2FF;
  color: #4338CA;
}

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

.btn-fav.is-fav {
  background: var(--emergency-bg);
  color: var(--emergency);
  border-color: var(--emergency);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  font-size: 15px;
}

.btn-step-prev, .btn-step-next {
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  font-size: 14px;
}

/* ---------- Step Navigation ---------- */
.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
  padding: 0 4px;
}

.step-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.step-dot.active {
  background: var(--primary);
  transform: scale(1.3);
}

/* ---------- Script all-list ---------- */
.script-all-title {
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
}

.script-all-title::after { content: ' \25BC'; font-size: 10px; }
.script-all-title.expanded::after { content: ' \25B2'; }

.script-all-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.script-all-list.expanded { max-height: 2000px; }

.mini-phrase {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mini-phrase:last-child { border-bottom: none; }
.mini-phrase.current { background: var(--primary-bg); border-radius: var(--radius-sm); }

.mini-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  min-width: 20px;
}

.mini-text {
  font-size: 14px;
  color: var(--text);
}

/* ---------- Search ---------- */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 18px;
  pointer-events: none;
  opacity: 0.5;
}

.search-input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font);
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus { border-color: var(--primary); }
.search-input::placeholder { color: var(--text-light); }

.search-results { margin-top: 16px; }

/* ---------- Show Overlay (full-screen) ---------- */
.show-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #111827;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-step {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.overlay-text {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.3;
  max-width: 90%;
  word-break: break-word;
}

.overlay-meaning {
  font-size: 16px;
  color: rgba(255,255,255,0.65);
  margin-top: 16px;
  font-style: italic;
  max-width: 90%;
}

.overlay-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-overlay-play, .btn-overlay-slow {
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  font-size: 15px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font);
}

.btn-overlay-slow {
  background: rgba(255,255,255,0.15);
}

.btn-overlay-copy {
  background: rgba(255,255,255,0.1);
  color: #fff;
  padding: 12px 20px;
  font-size: 15px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
}

.overlay-nav {
  display: flex;
  gap: 16px;
  margin-top: 32px;
}

.btn-overlay-prev, .btn-overlay-next {
  background: rgba(255,255,255,0.15);
  color: #fff;
  padding: 12px 24px;
  font-size: 15px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font);
}

/* ---------- Favorites / Empty ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}

/* ---------- Settings ---------- */
.settings-page { padding-bottom: 24px; }

.settings-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.settings-section h3 {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.lang-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.lang-btn.active {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.lang-flag { font-size: 22px; }

.speed-btns {
  display: flex;
  gap: 8px;
}

.speed-btn {
  flex: 1;
  padding: 12px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.2s, background 0.2s;
}

.speed-btn.active {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary-dark);
}

.tts-warning {
  margin-top: 10px;
  padding: 10px;
  background: var(--emergency-bg);
  border-radius: var(--radius-sm);
  color: var(--emergency);
  font-size: 13px;
}

.about-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---------- Loading / Error ---------- */
.loading-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 16px;
  min-height: 60vh;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Desktop enhancements ---------- */
@media (min-width: 481px) {
  body { background: #E5DDD5; }
  #app {
    box-shadow: 0 0 30px rgba(0,0,0,0.1);
    background: var(--bg);
  }
  .scenario-grid { grid-template-columns: 1fr 1fr 1fr; }
  .overlay-text { font-size: 42px; }
}
