/* ============================================
   InfoEmergenze.it — Emergency Info Service
   CSS Styles
   ============================================ */

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

:root {
  --primary:       #c62828;
  --primary-dark:  #8e0000;
  --primary-light: #ef5350;
  --bg:            #ffffff;
  --bg-alt:        #f5f5f5;
  --bg-dark:       #1a1a2e;
  --bg-dark-alt:   #16162a;
  --text:          #212121;
  --text-light:    #757575;
  --text-dark:     #ffffff;
  --border:        #e0e0e0;
  --warning:       #f57f17;
  --success:       #2e7d32;
  --info:          #1565c0;
  --min-touch:     48px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* --- Header --- */
header {
  background: var(--bg-dark);
  color: var(--text-dark);
  padding: 1.25rem 0;
  border-top: 4px solid var(--primary);
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

header h1 .red {
  color: var(--primary-light);
}

header h1 sup {
  font-size: 0.5em;
  font-weight: 600;
  color: var(--text-light);
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(198,40,40,0.6); }
  50% { opacity: 0.7; box-shadow: 0 0 0 8px rgba(198,40,40,0); }
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}

/* --- Sections --- */
section {
  padding: 1.5rem 0;
}

.section-alt {
  background: var(--bg-alt);
}

section > .container > h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--bg-dark);
  border-left: 4px solid var(--primary);
  padding-left: 0.75rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.section-header h2 {
  border: none;
  padding: 0;
  margin: 0;
  font-size: 1.4rem;
}

.section-link {
  font-size: 0.85rem;
  font-weight: 600;
}

.section-updated {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

/* --- Search --- */
#search-section {
  padding: 2rem 0 1rem;
}

#search-form {
  display: flex;
  gap: 0;
  border: 3px solid var(--primary);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(198,40,40,0.15);
}

#search-input {
  flex: 1;
  border: none;
  padding: 0.9rem 1.2rem;
  font-size: 1.05rem;
  font-family: inherit;
  outline: none;
  min-width: 0;
}

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

#search-form button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#search-form button:hover {
  background: var(--primary-dark);
}

/* Search Results */
.search-results {
  margin-top: 0.75rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.search-results:not([hidden]) {
  display: block;
}

.search-category {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.search-category:last-child {
  border-bottom: none;
}

.search-category h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem;
  border-radius: 4px;
  transition: background 0.15s;
  text-decoration: none !important;
  color: var(--text) !important;
}

.search-item:hover {
  background: var(--bg-alt);
}

.search-item-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.search-item-desc {
  font-size: 0.8rem;
  color: var(--text-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-item-arrow {
  margin-left: auto;
  color: var(--primary);
  font-weight: 700;
}

.no-results {
  padding: 1.5rem;
  text-align: center;
}

.no-results p {
  margin-bottom: 0.75rem;
  color: var(--text-light);
}

.web-search-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.web-search-btn:hover {
  background: var(--primary-dark);
}

/* --- Earthquake --- */
/* --- Quake embed iframe --- */
.quake-embed {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.quake-embed iframe {
  width: 100%;
  height: 500px;
  border: none;
  display: block;
}

.quake-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Quick links --- */
.quake-quicklinks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.quicklink {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-dark);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}

.quicklink:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-1px);
}

/* Quake count */
.quake-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-left: auto;
  white-space: nowrap;
}

/* Depth legend */
.depth-legend {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: white;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-light);
  flex-wrap: wrap;
}

.depth-legend span.legend-label {
  font-weight: 600;
  color: var(--text);
}

.depth-bar {
  display: flex;
  gap: 2px;
}

.depth-bar i {
  width: 20px;
  height: 10px;
  border-radius: 2px;
  display: block;
}

.depth-bar i:nth-child(1) { background: #FEB24C; }
.depth-bar i:nth-child(2) { background: #FD8D3C; }
.depth-bar i:nth-child(3) { background: #FC4E2A; }
.depth-bar i:nth-child(4) { background: #E31A1C; }
.depth-bar i:nth-child(5) { background: #BD0026; }
.depth-bar i:nth-child(6) { background: #800026; }

/* Alert channels section */
.alert-channels-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border);
}

.alert-channels-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bg-dark);
  margin-bottom: 0.75rem;
  border-left: 4px solid var(--info);
  padding-left: 0.5rem;
}

.quake-controls {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  align-items: center;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.control-label input[type="number"],
.control-label select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.9rem;
  font-family: inherit;
  min-height: var(--min-touch);
}

.loading {
  color: var(--text-light);
  font-style: italic;
  padding: 1rem 0;
}

.error-msg {
  background: #fff3e0;
  border-left: 4px solid var(--warning);
  padding: 0.75rem 1rem;
  border-radius: 0 6px 6px 0;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.empty-msg {
  color: var(--text-light);
  padding: 1rem 0;
  font-size: 0.9rem;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

#quake-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

#quake-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

#quake-table th {
  background: var(--bg-dark);
  color: white;
  padding: 0.6rem 0.8rem;
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

#quake-table td {
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 0.85rem;
}

#quake-table tbody tr:hover {
  background: #fff8f8;
}

#quake-table tbody tr:last-child td {
  border-bottom: none;
}

#quake-table td.mag {
  font-weight: 700;
  font-size: 1rem;
  min-width: 3.5rem;
  text-align: center;
}

.mag-green  { color: var(--success); border-left: 3px solid var(--success); }
.mag-yellow { color: var(--warning); border-left: 3px solid var(--warning); }
.mag-orange { color: #e65100; border-left: 3px solid #e65100; }
.mag-red    { color: var(--primary); border-left: 3px solid var(--primary); }

/* --- Source Tabs --- */
.source-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  min-height: var(--min-touch);
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content.active {
  display: block;
}

/* --- Source Grid --- */
.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.source-card {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: white;
  border-radius: 8px;
  padding: 1rem;
  border-top: 3px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none !important;
  color: var(--text) !important;
  min-height: var(--min-touch);
}

.source-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  text-decoration: none !important;
}

.source-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.source-card p {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.4;
}

.card-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}

/* --- Emergency Contacts --- */
#contacts-section h2 {
  border-left-color: var(--primary);
}

.contact-group {
  margin-bottom: 1.5rem;
}

.contact-group h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bg-dark);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.contact-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  text-decoration: none !important;
  color: var(--text) !important;
  transition: border-color 0.2s, box-shadow 0.2s;
  border-left: 4px solid var(--primary);
}

.contact-item:hover {
  border-left-color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  text-decoration: none !important;
}

.contact-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.contact-info {
  display: flex;
  flex-direction: column;
}

.contact-name {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
}

.contact-number {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.contact-note {
  font-size: 0.75rem;
  color: var(--text-light);
  line-height: 1.3;
}

/* --- Footer --- */
footer {
  background: var(--bg-dark);
  color: var(--text-light);
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.85rem;
  border-top: 4px solid var(--primary);
}

footer a {
  color: var(--primary-light);
}

.foot-note {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  color: #9e9e9e;
}

/* ============================================
   Breaking News Ticker
   ============================================ */

.breaking-ticker {
  display: flex;
  align-items: stretch;
  background: var(--primary);
  color: white;
  overflow: hidden;
  min-height: 40px;
}

.breaking-ticker[hidden] {
  display: none;
}

.ticker-label {
  background: rgba(0,0,0,0.2);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  z-index: 1;
}

.ticker-track {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.ticker-content {
  display: flex;
  align-items: center;
  white-space: nowrap;
  animation: ticker-scroll 60s linear infinite;
  width: max-content;
}

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-block;
  padding: 0.5rem 3rem 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  position: relative;
}

.ticker-item::before {
  content: '◆';
  position: absolute;
  right: 1rem;
  font-size: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.4;
}

.ticker-item[data-level="critical"] {
  background: rgba(198,40,40,0.15);
  border-left: 3px solid #ff8a80;
}

.ticker-item[data-level="warning"] {
  background: rgba(245,127,23,0.15);
  border-left: 3px solid #ffcc02;
}

.ticker-item[data-level="info"] {
  background: rgba(21,101,192,0.15);
  border-left: 3px solid #64b5f6;
}

/* ============================================
   News Feed Section
   ============================================ */

#news-feed-section {
  background: var(--bg-alt);
}

#news-feed-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 600px) {
  #news-feed-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  #news-feed-container {
    grid-template-columns: repeat(3, 1fr);
  }
}

.news-card {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  border-left: 4px solid var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.news-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.news-card[data-level="critical"] { border-left-color: #c62828; }
.news-card[data-level="warning"] { border-left-color: #f57f17; }
.news-card[data-level="info"]    { border-left-color: #1565c0; }

.news-source {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: white;
  background: var(--primary);
}

.news-source[data-level="critical"] { background: #c62828; }
.news-source[data-level="warning"]  { background: #f57f17; }
.news-source[data-level="info"]     { background: #1565c0; }

.news-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
}

.news-title a {
  color: var(--bg-dark);
}

.news-title a:hover {
  color: var(--primary);
}

.news-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

/* ============================================
   Responsive
   ============================================ */

/* Small phones */
@media (max-width: 480px) {
  header h1 {
    font-size: 1.4rem;
  }

  #search-form {
    flex-direction: column;
  }

  #search-input {
    padding: 0.8rem 1rem;
  }

  #search-form button {
    padding: 0.8rem;
  }

  .source-grid {
    grid-template-columns: 1fr;
  }

  .contact-list {
    grid-template-columns: 1fr;
  }

  .quake-controls {
    gap: 0.75rem;
  }

  section > .container > h2,
  .section-header h2 {
    font-size: 1.2rem;
  }

  #quake-table {
    font-size: 0.8rem;
  }

  #quake-table th,
  #quake-table td {
    padding: 0.4rem 0.5rem;
  }

  #quake-table td.mag {
    font-size: 0.9rem;
  }

  .tab-btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
}

/* Tablets */
@media (min-width: 481px) and (max-width: 768px) {
  .source-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .contact-list {
    grid-template-columns: repeat(2, 1fr);
  }

  header h1 {
    font-size: 1.6rem;
  }
}

/* Desktop */
@media (min-width: 769px) {
  section {
    padding: 2rem 0;
  }

  header {
    padding: 1.5rem 0;
  }

  header h1 {
    font-size: 2rem;
  }

  .tab-btn {
    padding: 0.85rem 1.5rem;
  }
}

/* Large desktop */
@media (min-width: 1025px) {
  .container {
    padding: 0 2rem;
  }

  .source-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}
