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

:root {
  --bg: #050e1a;
  --surface: #0c1a2e;
  --surface2: #112237;
  --surface3: #162c46;
  --border: rgba(34, 211, 238, 0.12);
  --accent: #22d3ee;
  --accent2: #34d399;
  --accent-glow: rgba(34, 211, 238, 0.22);
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --red: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="light"] {
  --bg: #f0fafa;
  --surface: #ffffff;
  --surface2: #e8f8fb;
  --surface3: #cef0f5;
  --border: rgba(8, 145, 178, 0.18);
  --accent: #0891b2;
  --accent2: #059669;
  --accent-glow: rgba(8, 145, 178, 0.15);
  --text: #1e293b;
  --text-muted: #64748b;
  --text-soft: #475569;
  --red: #dc2626;
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(8, 145, 178, 0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 0%, rgba(5, 150, 105, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(8, 145, 178, 0.04) 0%, transparent 50%);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(34, 211, 238, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 0%, rgba(52, 211, 153, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(34, 211, 238, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Page Wrapper ===== */
.page-wrapper {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 60px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Cookie Banner ===== */
.cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(5, 14, 26, 0.97);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  z-index: 1000;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.cookie-banner.show { transform: translateY(0); }

.cookie-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.cookie-text {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-soft);
  min-width: 200px;
}

.cookie-text strong { color: var(--accent); }
.cookie-btns { display: flex; gap: 8px; }

.cookie-accept {
  padding: 8px 20px;
  background: var(--accent);
  color: #050e1a;
  border: none;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.2s;
}

.cookie-accept:hover { filter: brightness(1.1); }

.cookie-decline {
  padding: 8px 20px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

/* ===== Header ===== */
.site-header {
  text-align: center;
  padding: 48px 0 36px;
  position: relative;
}

.header-top {
  position: absolute;
  top: 16px; right: 0;
  display: flex;
  justify-content: flex-end;
}

.theme-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.theme-btn:hover {
  border-color: var(--accent);
  background: var(--surface3);
  transform: rotate(20deg);
}

.header-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 14px;
  display: block;
  filter: drop-shadow(0 0 24px rgba(34, 211, 238, 0.5));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

.site-header h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #a5f3fc 0%, #22d3ee 45%, #34d399 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.site-header p {
  color: var(--text-soft);
  font-size: 1rem;
}

/* ===== Main ===== */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 4px 40px rgba(0, 0, 0, 0.35);
}

/* ===== Section Title ===== */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title span { font-size: 1rem; }

/* ===== Location Section ===== */
.location-inputs {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.manual-location {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 260px;
}

.or-divider {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  flex-shrink: 0;
}

input[type="text"] {
  flex: 1;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 11px 18px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]::placeholder { color: var(--text-muted); }

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0e7490);
  color: #050e1a;
  border: none;
  border-radius: 50px;
  padding: 11px 22px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(34, 211, 238, 0.35);
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(34, 211, 238, 0.5);
}

.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: var(--surface2);
  color: var(--text-soft);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 11px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface3);
}

.current-location {
  font-size: 0.85rem;
  color: var(--accent2);
  font-style: italic;
  min-height: 1.2em;
}

/* ===== Loading ===== */
.loading-state {
  text-align: center;
  padding: 48px 20px;
  animation: fadeUp 0.3s ease-out;
}

.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--surface3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

.loading-state p { color: var(--text-soft); font-size: 0.9rem; }

/* ===== Error ===== */
.error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  color: var(--red);
  font-size: 0.9rem;
  animation: fadeUp 0.3s ease-out;
}

/* ===== Visibility Meter ===== */
.visibility-meter {
  text-align: center;
  margin-bottom: 24px;
}

.percentage {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #a5f3fc, #22d3ee, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 14px;
}

.meter-bar {
  width: 100%;
  max-width: 480px;
  margin: 0 auto 12px;
  height: 12px;
  background: var(--surface2);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #34d399, #22d3ee, #0ea5e9);
  border-radius: 6px;
  transition: width 1s ease;
  width: 0%;
}

.visibility-desc {
  font-size: 0.95rem;
  color: var(--text-soft);
  font-weight: 500;
}

/* ===== Conditions Grid ===== */
.conditions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.condition-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  border-left: 3px solid var(--accent);
}

.condition-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.condition-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}

/* ===== Forecast Grid ===== */
.forecast-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.forecast-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  text-align: center;
  transition: border-color 0.2s, transform 0.2s;
}

.forecast-item:hover {
  border-color: rgba(34, 211, 238, 0.4);
  transform: translateY(-2px);
}

.forecast-date {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.forecast-percentage {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.forecast-kp {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ===== History Chart ===== */
#historyChart {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
}

/* ===== Info Grid ===== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.info-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  border-left: 3px solid var(--accent2);
}

.info-item h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent2);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.info-item p {
  font-size: 0.85rem;
  color: var(--text-soft);
  line-height: 1.55;
}

/* ===== Install Banner ===== */
.install-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-top: 20px;
  display: none;
  gap: 14px;
  align-items: flex-start;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  animation: fadeUp 0.35s ease-out;
}

.install-banner.visible { display: flex; }

.install-banner-icon { font-size: 1.8rem; flex-shrink: 0; line-height: 1; }
.install-banner-body { flex: 1; min-width: 0; }

.install-banner-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.install-banner-text {
  font-size: 0.8rem;
  color: var(--text-soft);
  line-height: 1.55;
}

.install-banner-text kbd {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--text);
}

.install-banner-actions { display: flex; gap: 8px; margin-top: 12px; }

.install-btn {
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.install-btn-primary {
  background: var(--accent);
  color: #050e1a;
  box-shadow: 0 2px 12px rgba(34, 211, 238, 0.35);
}

.install-btn-primary:hover { filter: brightness(1.1); }

.install-btn-dismiss {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border) !important;
}

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

.install-banner-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0 0 6px;
  flex-shrink: 0;
  line-height: 1;
  align-self: flex-start;
}

.install-banner-close:hover { color: var(--text); }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 28px 0 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-top: auto;
}

.site-footer a { color: var(--text-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.4);
  padding: 36px 32px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  line-height: 1.7;
}

.modal-content h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}

.modal-content h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 20px;
  margin-bottom: 6px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-content p {
  font-size: 0.88rem;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.modal-content a { color: var(--accent2); }

.modal-close {
  position: absolute;
  top: 14px; right: 18px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

/* ===== Utilities ===== */
.hidden { display: none !important; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .forecast-grid { grid-template-columns: repeat(4, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
  .conditions-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .site-header h1 { font-size: 1.75rem; }
  .card { padding: 18px; }
  .location-inputs { flex-direction: column; align-items: stretch; }
  .or-divider { text-align: center; }
  .manual-location { flex-direction: column; min-width: auto; }
  .forecast-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .percentage { font-size: 3rem; }
  .modal-content { padding: 24px 18px; }
  .cookie-inner { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 380px) {
  .forecast-grid { grid-template-columns: repeat(2, 1fr); }
}
