/* house_web — site styles. Mobile-first; no external resources. */

/* ---------- Tokens ----------
   Light is the default. Dark applies when the visitor's system prefers it
   (no JS) or when theme-init.js sets data-theme="dark". Keep the two dark
   blocks identical. tools/contrast.mjs reads these hex values. */
:root {
  color-scheme: light;
  --bg: #f7f5f0;
  --bg-alt: #edeae2;
  --surface: #ffffff;
  --text: #1f2421;
  --text-muted: #3f4641;
  --accent: #344e3c;
  --accent-strong: #2c4232;
  --border: #7b847d;
  --border-soft: #d9d5cb;
  --focus: #344e3c;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 14px rgb(0 0 0 / 0.07);
  --viewer-bg: #0e100f;
  --viewer-text: #f2f0eb;
  --hero-text: #ffffff;
  --hero-scrim: rgb(12 14 13 / 0.72);

  --radius: 6px;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --content: 72rem;
  --measure: 65ch;
  --header-h: 4rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1b1e1c;
    --bg-alt: #222623;
    --surface: #282c29;
    --text: #ece9e2;
    --text-muted: #cfcbc2;
    --accent: #a9c7a6;
    --accent-strong: #c3dbc0;
    --border: #8a948c;
    --border-soft: #3a403c;
    --focus: #a9c7a6;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 14px rgb(0 0 0 / 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1e1c;
  --bg-alt: #222623;
  --surface: #282c29;
  --text: #ece9e2;
  --text-muted: #cfcbc2;
  --accent: #a9c7a6;
  --accent-strong: #c3dbc0;
  --border: #8a948c;
  --border-soft: #3a403c;
  --focus: #a9c7a6;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 14px rgb(0 0 0 / 0.35);
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  overflow-wrap: break-word;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  margin: 0 0 0.6em;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h2 { font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.25rem); }
h3 { font-size: clamp(1.3rem, 1.1rem + 0.9vw, 1.6rem); }
h4 { font-size: 1.15rem; }

p { margin: 0 0 1em; max-width: var(--measure); }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-strong);
  text-decoration-thickness: 2px;
}

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

/* Headings receive focus from the section menu; keep the ring off the text. */
[tabindex="-1"]:focus-visible {
  outline-offset: 6px;
  border-radius: 2px;
}

main:focus {
  outline: none;
}

.tbd {
  color: var(--text-muted);
  font-style: italic;
}

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

.wrap {
  max-width: var(--content);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ---------- Buttons (shared) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.2;
  cursor: pointer;
}

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

.btn svg {
  width: 1.1em;
  height: 1.1em;
  flex: none;
}

/* ---------- Header and section menu ---------- */
.site-header {
  position: relative;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  z-index: 50;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding-block: 0.5rem;
}

.brand {
  margin: 0;
  margin-inline-end: auto;
  font-weight: 650;
  font-size: clamp(0.9rem, 0.8rem + 0.5vw, 1.05rem);
  line-height: 1.3;
}

@media (min-width: 75em) {
  .header-inner {
    column-gap: 1rem;
  }
}

.site-nav {
  order: 3;
  flex-basis: 100%;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.25rem 0.45rem;
  color: var(--text);
  font-size: 1rem;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.nav-list a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.nav-list a[aria-current="true"] {
  border-bottom-color: var(--accent);
  font-weight: 650;
}

/* Hidden until JS shows it (theme-init.js / nav.js). */
.nav-toggle,
.theme-toggle {
  display: none;
}

.js .theme-toggle {
  display: inline-flex;
}

.theme-toggle .icon-sun { display: none; }

/* Icon-only: there's no room for a visible label beside the menu. The
   accessible name, "Dark theme", comes from the visually hidden text. */
.theme-toggle {
  padding-inline: 0.5rem;
}

.theme-toggle[aria-pressed="true"] .icon-moon { display: none; }
.theme-toggle[aria-pressed="true"] .icon-sun { display: block; }

/* Narrow screens: with JS the links collapse behind "Sections" and open as a
   panel under the header. */
@media (max-width: 47.99em) {
  .js .site-nav {
    order: 0;
    flex-basis: auto;
  }

  .js .nav-toggle {
    display: inline-flex;
  }

  .js .nav-list:not(.is-open) {
    display: none;
  }

  .js .nav-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    padding: 0.25rem var(--gutter) 0.75rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: var(--shadow);
  }
}

/* Brand, menu and theme button share one row only when they all fit. */
@media (min-width: 75em) {
  .site-nav {
    order: 0;
    flex-basis: auto;
  }

  .brand {
    margin-inline-end: 0;
  }

  .site-nav {
    margin-inline-end: auto;
  }
}

/* Sticky only when there is room for it (not at high zoom or short screens). */
@media (min-height: 30em) {
  .site-header {
    position: sticky;
    top: 0;
  }

  section[id],
  .room h3[id] {
    scroll-margin-top: calc(var(--header-h) + 1rem);
  }
}

/* Without JS on narrow screens the full menu is visible, so don't stick. */
@media (max-width: 47.99em) {
  html:not(.js) .site-header {
    position: static;
  }
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  margin: 0;
  background: var(--viewer-bg);
}

.hero > * {
  grid-area: 1 / 1;
}

.hero img {
  width: 100%;
  height: 100%;
  min-height: clamp(18rem, 60vw, 40rem);
  max-height: 80vh;
  object-fit: cover;
}

/* The scrim sits behind all hero text, so contrast holds over any photo:
   transparent above the text, at least --hero-scrim behind it. */
.hero-text {
  align-self: end;
  padding: 5rem var(--gutter) clamp(1.25rem, 4vw, 2.5rem);
  color: var(--hero-text);
  background: linear-gradient(to top, var(--hero-scrim) 0, var(--hero-scrim) calc(100% - 5rem), transparent 100%);
}

.hero-text > * {
  max-width: calc(var(--content) - 2 * var(--gutter));
  margin-inline: auto;
}

.hero h1 {
  font-size: clamp(1.9rem, 1.2rem + 3.5vw, 3.5rem);
  margin-bottom: 0.25em;
}

.hero .price {
  font-size: clamp(1.25rem, 1rem + 1.2vw, 1.75rem);
  font-weight: 600;
  margin-bottom: 0;
}

.hero .location {
  margin-bottom: 0.25em;
}

/* ---------- Sections ---------- */
.section {
  padding-block: clamp(2.5rem, 6vw, 4.5rem);
}

.section:nth-of-type(even) {
  background: var(--bg-alt);
}

.section-intro {
  font-size: 1.1rem;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
  padding: 0;
}

.facts div {
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.facts dt {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.facts dd {
  margin: 0;
  font-weight: 600;
}

.note {
  padding: 0.75rem 1rem;
  border-inline-start: 4px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  max-width: var(--measure);
}

/* ---------- Room blocks ---------- */
.room {
  margin-top: clamp(2rem, 5vw, 3.5rem);
}

.part {
  margin-top: 1.75rem;
}

.room-body {
  display: grid;
  gap: 1rem 2.5rem;
  align-items: start;
}

@media (min-width: 60em) {
  .room-body {
    grid-template-columns: 3fr 2fr;
  }

  .room-body.flip {
    grid-template-columns: 2fr 3fr;
  }

  .room-body.flip .lead {
    order: 2;
  }
}

.lead {
  margin: 0;
}

.lead figcaption {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* The "print on a mat" frame shared by lead photos and thumbnails. */
.photo-link {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
}

.photo-link img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  transition: opacity 0.2s ease;
}

.photo-link:hover img {
  opacity: 0.9;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr));
  gap: 0.75rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 60em) {
  .thumbs {
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  }
}

/* ---------- Contact ---------- */
.contact-list {
  margin: 1rem 0 1.5rem;
  padding: 0;
  list-style: none;
  font-size: 1.1rem;
}

.contact-list li {
  margin-bottom: 0.4rem;
}

/* ---------- Footer ---------- */
.site-footer {
  padding-block: 2.5rem 3rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.95rem;
}

.site-footer h2 {
  font-size: 1.2rem;
}

.site-footer .contact-list {
  font-size: inherit;
}

.disclaimer {
  color: var(--text-muted);
}

.credits summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
}

.credits ul {
  padding-inline-start: 1.25rem;
  color: var(--text-muted);
}

/* ---------- Photo viewer ---------- */
.viewer {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--viewer-bg);
  color: var(--viewer-text);
}

.viewer::backdrop {
  background: rgb(0 0 0 / 0.85);
}

.viewer[open] {
  display: flex;
  flex-direction: column;
}

.viewer-bar,
.viewer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem var(--gutter);
}

.viewer-title {
  margin: 0;
  margin-inline-end: auto;
  font-size: 1.1rem;
}

.viewer-count {
  margin: 0;
}

.viewer-figure {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding-inline: var(--gutter);
  touch-action: pan-y pinch-zoom; /* let horizontal swipes reach gallery.js */
}

.viewer-figure picture {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

/* Room left for the bar, caption and buttons around the photo. */
.viewer-figure img {
  max-width: 100%;
  max-height: calc(100vh - 12rem);
  max-height: calc(100dvh - 12rem);
  width: auto;
  height: auto;
  object-fit: contain;
}

.viewer-figure figcaption {
  padding-top: 0.5rem;
  text-align: center;
  max-width: var(--measure);
}

.viewer-nav {
  justify-content: center;
}

.viewer .btn {
  background: transparent;
  color: var(--viewer-text);
  border-color: #9aa39c;
}

.viewer .btn:hover {
  background: rgb(255 255 255 / 0.08);
}

.viewer :focus-visible {
  outline-color: #c3dbc0;
}

.viewer-nav .btn {
  min-width: 8rem;
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  html:focus-within {
    scroll-behavior: smooth;
  }

  .viewer[open] {
    animation: fade-in 0.18s ease-out;
  }

  .viewer-figure img.is-changing {
    animation: fade-in 0.2s ease-out;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Forced colors (Windows High Contrast) ---------- */
@media (forced-colors: active) {
  .photo-link,
  .btn,
  .facts div,
  .note {
    border: 1px solid CanvasText;
  }

  .nav-list a[aria-current="true"] {
    border-bottom-color: Highlight;
  }
}
