/* OpenWindow.live — minimalist, time.is-inspired */

:root {
  --bg: #fafafa;
  --bg-soft: #f0f0f0;
  --fg: #0a0a0a;
  --fg-soft: #555;
  --fg-faint: #888;
  --border: #e5e5e5;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow: #ca8a04;
  --yellow-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --bg-soft: #161616;
    --fg: #f5f5f5;
    --fg-soft: #aaa;
    --fg-faint: #666;
    --border: #262626;
    --green-bg: #052e16;
    --yellow-bg: #422006;
    --red-bg: #450a0a;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
  font-size: 17px;
}

.brand-icon { font-size: 22px; }
.brand-tld { color: var(--fg-faint); font-weight: 400; }

#lang-switcher {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--fg);
  cursor: pointer;
  min-height: 44px;
}

/* Main */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  max-width: 580px;
  margin: 0 auto;
  width: 100%;
}

.question {
  font-size: clamp(22px, 5vw, 32px);
  font-weight: 600;
  text-align: center;
  margin-bottom: 32px;
  letter-spacing: -0.01em;
}

/* States */
.state {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* Loading inline form */
#loading form {
  opacity: 0;
  animation: fadeIn 0.4s ease 1.5s forwards;
  max-width: 360px;
}

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

/* Loading */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Status card */
.status {
  width: 100%;
  text-align: center;
  padding: 40px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background 0.3s ease;
}

.status-green { background: var(--green-bg); }
.status-yellow { background: var(--yellow-bg); }
.status-red { background: var(--red-bg); }

.status-emoji {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 12px;
}

.status-word {
  font-size: clamp(36px, 9vw, 56px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.status-green .status-word { color: var(--green); }
.status-yellow .status-word { color: var(--yellow); }
.status-red .status-word { color: var(--red); }

.status-reason {
  font-size: 16px;
  color: var(--fg-soft);
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.45;
}

/* Details grid */
.details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
}

.detail {
  background: var(--bg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-full {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  font-weight: 600;
}

.detail-value {
  font-size: 16px;
  color: var(--fg);
  font-weight: 500;
}

/* Actions */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 44px;
}

.btn-ghost:hover { background: var(--bg-soft); }

.btn-link {
  background: none;
  border: none;
  color: var(--fg-soft);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  font-size: inherit;
  padding: 6px 2px;
}

.btn-link:hover { color: var(--fg); }

.updated {
  font-size: 13px;
  color: var(--fg-faint);
  text-align: center;
}

/* Forms */
form {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 400px;
}

/* Autocomplete */
.ac-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.ac-wrap input[type="text"] {
  width: 100%;
}

.ac-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  max-height: 220px;
  overflow-y: auto;
}

.ac-list li {
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-list li + li {
  border-top: 1px solid var(--border);
}

.ac-list li:hover,
.ac-list li.active {
  background: var(--bg-soft);
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--fg);
}

input:focus, select:focus {
  outline: 2px solid var(--fg);
  outline-offset: -1px;
}

button[type="submit"],
#settings-save,
#error-retry {
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
}

#settings label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  font-size: 14px;
  color: var(--fg-soft);
}

#settings { gap: 16px; max-width: 400px; }

#settings h2 {
  font-size: 20px;
  font-weight: 600;
}

/* Error */
.error-msg {
  color: var(--red);
  font-size: 16px;
  text-align: center;
}

/* Footer */
footer {
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: var(--fg-faint);
  border-top: 1px solid var(--border);
}

footer a {
  color: var(--fg-soft);
  text-decoration: none;
}

footer a:hover { text-decoration: underline; }

.footer-credit {
  margin-top: 6px;
  font-size: 12px;
}

/* Responsive */
@media (max-width: 480px) {
  main {
    padding: 20px 16px;
    padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 16px));
  }
  .status { padding: 24px 16px; }
  .details { grid-template-columns: 1fr; }
  .actions { flex-direction: column; width: 100%; gap: 10px; }
  .btn-ghost { width: 100%; }
  form { flex-direction: column; }
  form button[type="submit"] { width: 100%; }
}

@media (max-width: 360px) {
  .question { font-size: 20px; margin-bottom: 20px; }
  .status-emoji { font-size: 52px; }
  .status-reason { font-size: 15px; }
  #settings h2 { font-size: 18px; }
}

/* City pages — content sections below the tool */
.city-sections {
  max-width: 580px;
  margin: 0 auto;
  padding: 0 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.city-section-title {
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-faint);
  margin-bottom: 12px;
}

/* FAQ accordion */
.faq-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}

.faq-item:last-child { border-bottom: none; }

.faq-item summary {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--fg);
}

.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; font-size: 20px; color: var(--fg-faint); flex-shrink: 0; line-height: 1; }
.faq-item[open] summary::after { content: '−'; }

.faq-item p {
  padding: 0 16px 14px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--fg-soft);
  margin: 0;
}

/* Related cities */
.related-cities-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.related-city-link {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 14px;
  color: var(--fg-soft);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.related-city-link:hover {
  background: var(--bg-soft);
  border-color: var(--fg-faint);
  color: var(--fg);
}

/* City intro line */
.city-intro {
  font-size: 14px;
  color: var(--fg-faint);
  text-align: center;
  margin-top: -20px;
  margin-bottom: 8px;
}

@media (max-width: 480px) {
  .city-sections { padding: 0 16px 36px; }
  .faq-item summary { padding: 12px 14px; font-size: 14px; }
  .faq-item p { padding: 0 14px 12px; font-size: 14px; }
}
