:root {
  /* Always light, whatever the visitor's dark-mode preference (owner's choice). */
  color-scheme: light;
  --bg: #ffffff; /* the logo's own white */
  --surface: #ffffff;
  --text: #1c1f23;
  --muted: #5d656e;
  --border: #d3d7db;
  --accent: #0072b2;
  --accent-text: #ffffff;
  --accent2: #d55e00;
  --thumb-bg: #f1f1ee;
  --radius: 8px;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

h1, h2 { line-height: 1.2; margin: 0 0 0.75rem; }
h2 { font-size: 1.5rem; }
a { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--accent2);
  outline-offset: 2px;
}

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

/* --- top bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.5rem var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 1rem; }
.nav a { color: var(--text); text-decoration: none; padding: 0.25rem 0; }
.nav a:hover { color: var(--accent); text-decoration: underline; }
.topbar-end { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }
.github { display: inline-flex; color: var(--text); }
.github:hover { color: var(--accent); }

select, input:not([type="color"]):not([type="file"]) {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.6rem;
}
input[type="color"] {
  width: 3.5rem;
  height: 2.25rem;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* --- views --- */
.view { max-width: 1000px; margin: 0 auto; padding: 1.5rem var(--gutter) 3rem; }
.view[hidden], [hidden] { display: none !important; }

/* Long texts (About): a readable line length. */
.prose { max-width: 42rem; line-height: 1.6; }
.prose p { margin: 0 0 1rem; }

.hero { text-align: center; padding: 2rem 0; }
.hero h1 { margin: 0 0 1rem; line-height: 0; }
.hero-logo { width: min(240px, 70vw); height: auto; }
.tagline { color: var(--muted); font-size: 1.15rem; margin: 0 auto 1.5rem; max-width: 34rem; }
/* Landing carousel: one sundial at a time, arrows on both sides. */
.carousel { display: flex; align-items: center; gap: 0.5rem; }
.carousel figure { flex: 1; min-width: 0; margin: 0; }
.carousel img {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
}
.carousel figcaption { margin-top: 0.5rem; text-align: center; color: var(--muted); font-size: 0.9rem; }
.carousel-step {
  flex: 0 0 auto; width: 2.5rem; height: 2.5rem; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.carousel-step:hover { border-color: var(--accent); color: var(--accent); }

/* --- buttons --- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  font: inherit;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.button.primary { color: var(--accent-text); background: var(--accent); }
.button.primary:hover { filter: brightness(1.1); }
.button:disabled, .button[disabled] { opacity: 0.5; cursor: not-allowed; filter: none; }
.actions { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }

.link {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0.35rem 0;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
  overflow-wrap: anywhere;
}

/* --- location --- */
.search { display: flex; gap: 0.5rem; }
.search input { flex: 1; min-width: 0; }
.search-results { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.search-results li { border-bottom: 1px solid var(--border); }
.status { color: var(--muted); font-size: 0.875rem; margin: 0.5rem 0; min-height: 1.25rem; }
.status[role="alert"] { color: var(--text); font-size: 1rem; }
.site-footer { color: var(--muted); font-size: 0.75rem; text-align: center; padding: 0 var(--gutter) 1.5rem; min-height: 1rem; }
.map {
  height: 60vh;
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 0;
}
.place { font-weight: 600; margin: 0.75rem 0 0; min-height: 1.5rem; }

/* --- details form --- */
fieldset {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
legend { padding: 0 0.5rem; font-weight: 600; }
#details-form label { display: block; margin-top: 0.75rem; }
#details-form label > span { display: block; margin-bottom: 0.25rem; color: var(--muted); font-size: 0.9rem; }
#details-form input:not([type="color"]):not([type="file"]) { width: 100%; }
.periods { display: grid; gap: 0; grid-template-columns: 1fr; }

.image-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
}
.image-choice > span { flex: 0 0 100%; color: var(--muted); font-size: 0.9rem; }
#details-form .image-choice label.button { display: inline-flex; margin-top: 0; }
#details-form .image-choice label.button > span { display: inline; margin: 0; color: inherit; font-size: inherit; }
.thumb {
  max-height: 64px;
  max-width: 96px;
  object-fit: contain;
  background: var(--thumb-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* --- submit spinner --- */
.spinner { display: none; }
.busy .spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .busy .spinner { animation: none; }
}

/* --- result --- */
.previews { display: grid; gap: 1.5rem; margin: 0; }
.previews figure { margin: 0; }
.previews img { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--border); }
.previews figcaption { text-align: center; color: var(--muted); margin-top: 0.5rem; }

@media (min-width: 720px) {
  .view { padding-top: 2rem; }
  .hero-logo { width: 340px; }
  .hero { padding: 3rem 0; }
  .periods { grid-template-columns: 1fr 1fr; gap: 1rem; }
  .image-choice > span { flex: 0 0 8rem; }
}
