/* ═══════════════════════════════════════════════════
   CityTime — main.css
   Shared layout, toolbar, nav, modal, utilities
   ═══════════════════════════════════════════════════ */

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

:root {
  --toolbar-h:  52px;
  --edit-bar-h: 52px;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(0,0,0,.35);
  --t-fast:     150ms ease;
  --t-med:      280ms ease;
  --font-ui:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num:   ui-monospace, "SF Mono", "Cascadia Mono", "Consolas", monospace;
  --accent:       #22d3ee;
  --accent-hover: #06b6d4;
}

/* ── Accent colors ────────────────────────────────── */
body.accent-cyan { --accent: #22d3ee; --accent-hover: #06b6d4; }
body.accent-rose { --accent: #fb7185; --accent-hover: #f43f5e; }

/* ── Background tints per accent × theme ─────────── */
body.theme-dark.accent-cyan  { --bg: #080f14; --surface: #0e1c27; --surface-2: #152433; }
body.theme-dark.accent-rose  { --bg: #130a0d; --surface: #1f1118; --surface-2: #2a1822; }
body.theme-light.accent-cyan { --bg: #e8f5f8; --surface: #f5fcff; --surface-2: #dceef4; }
body.theme-light.accent-rose { --bg: #f8eef1; --surface: #fff5f7; --surface-2: #f0e0e6; }

/* ── Dark theme ───────────────────────────────────── */
.theme-dark {
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --surface-2:    #22263a;
  --border:       rgba(255,255,255,.08);
  --text-pri:     #f0f2f8;
  --text-sec:     #8890a8;
  --text-muted:   #555e7a;
  --day-tint:     rgba(255,220,80,.045);
  --night-tint:   rgba(30,40,80,.55);
  --badge-dst:    rgba(255,180,0,.18);
  --badge-wkd:    rgba(100,200,120,.18);
  --badge-dst-txt:#f5c842;
  --badge-wkd-txt:#6fcf97;
  --toolbar-bg:   rgba(15,17,23,.88);
  --modal-bg:     #1a1d27;
  --overlay:      rgba(0,0,0,.65);
}

/* ── Light theme ──────────────────────────────────── */
.theme-light {
  --bg:           #f0f2f7;
  --surface:      #ffffff;
  --surface-2:    #e8eaf2;
  --border:       rgba(0,0,0,.09);
  --text-pri:     #1a1d2e;
  --text-sec:     #555e7a;
  --text-muted:   #9099b8;
  --day-tint:     rgba(255,220,80,.12);
  --night-tint:   rgba(30,40,80,.12);
  --badge-dst:    rgba(200,140,0,.14);
  --badge-wkd:    rgba(20,160,80,.12);
  --badge-dst-txt:#b45309;
  --badge-wkd-txt:#166534;
  --toolbar-bg:   rgba(240,242,247,.9);
  --modal-bg:     #ffffff;
  --overlay:      rgba(0,0,0,.4);
}

html, body {
  height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-pri);
  transition: background var(--t-med), color var(--t-med);
  overflow-x: hidden;
}

/* ── Toolbar (world-clock page) ───────────────────── */
.toolbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--toolbar-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--toolbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: opacity var(--t-med), transform var(--t-med), background var(--t-med);
  gap: 8px;
}
.toolbar.hidden-toolbar { opacity: 0; pointer-events: none; transform: translateY(-100%); }

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 4px; }

.app-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text-pri);
  white-space: nowrap;
}

.toolbar-logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-pri);
  text-decoration: none;
  letter-spacing: -.01em;
  white-space: nowrap;
  margin-right: 4px;
}
.toolbar-logo:hover { color: var(--accent); }

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: none;
  background: transparent;
  color: var(--text-sec);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
}
.toolbar-btn:hover       { background: var(--surface-2); color: var(--text-pri); }
.toolbar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toolbar-btn.active      { color: var(--accent); }
.toolbar-btn svg         { width: 18px; height: 18px; }

.format-btn {
  width: auto; padding: 0 10px;
  font-family: var(--font-num);
  font-size: .8rem; font-weight: 600; letter-spacing: .04em;
}

/* ── Site nav (homepage + city pages) ────────────── */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--toolbar-h);
  background: var(--toolbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 8px;
}
.nav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-pri);
  text-decoration: none;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.nav-logo:hover { color: var(--accent); }
.nav-sep   { color: var(--text-sec); opacity: .4; font-size: .9rem; }
.nav-page  { font-size: .88rem; color: var(--text-sec); }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link  {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-sec);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--text-pri); }
.nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Edit bar ─────────────────────────────────────── */
.edit-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--edit-bar-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--toolbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.edit-hint { font-size: .8rem; color: var(--text-sec); }

.btn-primary {
  padding: 7px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
}
.btn-primary:hover        { background: var(--accent-hover); }
.btn-primary:active       { transform: scale(.97); }
.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── Modal ────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: max(60px, 10vh);
  padding-inline: 16px;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--overlay);
  z-index: -1;
}
.modal-content {
  background: var(--modal-bg);
  border-radius: 14px;
  width: 100%; max-width: 480px; max-height: 70vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
  border: 1px solid var(--border);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 0;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: transparent;
  color: var(--text-sec); border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.modal-close:hover { background: var(--surface-2); color: var(--text-pri); }
.modal-close svg { width: 16px; height: 16px; }
.modal-close:focus-visible { outline: 2px solid var(--accent); }

.city-search-input {
  margin: 12px 16px 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-pri);
  font-size: .9rem; font-family: var(--font-ui);
  outline: none;
  transition: border-color var(--t-fast);
}
.city-search-input::placeholder { color: var(--text-muted); }
.city-search-input:focus        { border-color: var(--accent); }

.search-results { list-style: none; overflow-y: auto; flex: 1; padding: 0 8px 8px; }
.search-results li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 8px; border-radius: 8px; cursor: pointer; gap: 12px;
  transition: background var(--t-fast);
}
.search-results li:hover, .search-results li.focused { background: var(--surface-2); }
.search-results li:focus-visible { outline: 2px solid var(--accent); }

.result-info   { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.result-city   { font-size: .88rem; font-weight: 500; color: var(--text-pri); }
.result-country { font-size: .73rem; color: var(--text-muted); }
.result-time   { font-family: var(--font-num); font-size: .82rem; font-variant-numeric: tabular-nums; color: var(--text-sec); white-space: nowrap; flex-shrink: 0; }
.result-already { font-size: .7rem; color: var(--text-muted); font-style: italic; }

.search-empty { text-align: center; color: var(--text-muted); font-size: .85rem; padding: 24px 16px; }

/* ── Toast ────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--surface-2);
  color: var(--text-pri);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 8px 20px;
  font-size: .85rem; font-weight: 500;
  z-index: 300;
  box-shadow: var(--shadow);
  transition: opacity var(--t-fast), transform var(--t-fast);
  pointer-events: none;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(12px); }

/* ── Footer ───────────────────────────────────────── */
.site-footer {
  text-align: center;
  font-size: .75rem;
  color: var(--text-muted);
  padding: 16px 16px 24px;
  line-height: 1.5;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.site-footer a { color: var(--text-muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: -100%; left: 16px; z-index: 9999;
  padding: 8px 16px;
  background: var(--accent); color: #fff;
  border-radius: 0 0 8px 8px;
  font-size: .85rem; font-weight: 600;
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 0; }

/* ── Scrollbar ────────────────────────────────────── */
.search-results::-webkit-scrollbar       { width: 6px; }
.search-results::-webkit-scrollbar-track { background: transparent; }
.search-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 599px) {
  .modal { padding-top: 0; align-items: flex-end; }
  .modal-content { max-height: 80vh; border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-width: 100%; }
}
@media (max-width: 380px) {
  .app-title { display: none; }
  .toolbar-btn { width: 36px; height: 36px; }
  .nav-link span { display: none; }
}
@media (max-height: 500px) and (orientation: landscape) {
  :root { --toolbar-h: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
