/* übersteigert.de – layout modelled on the former Adobe Portfolio theme "Jess" */

:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #8a8a8a;      /* nav and meta text (#aaa of the old site fails contrast) */
  --line: #e6e6e6;
  --accent: #111111;
  --error: #b00020;
  --gap: 8px;
  --row: 320px;          /* justified grid row height – keep in sync with GRID_ROW in site.py */
  --side: clamp(16px, 4vw, 48px);
  --max: 1400px;
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
}

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

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

.skip-link {
  position: absolute; left: var(--side); top: -100px;
  background: var(--text); color: var(--bg); padding: 8px 12px; z-index: 100;
}
.skip-link:focus { top: 8px; }

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

/* --- Header --------------------------------------------------------------- */

.site-header {
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px var(--side) 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 32px;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.01em;
}
.logo-tagline { font-weight: 300; color: var(--muted); }

.main-nav { margin-left: auto; }
.main-nav ul { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0; padding: 0; list-style: none; }
.main-nav a,
.lang-switch {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  font-size: 15px;
  letter-spacing: 0.06em;
}
.main-nav a:hover, .main-nav a[aria-current], .lang-switch:hover { color: var(--text); }

.header-actions { display: flex; align-items: center; gap: 20px; }
/* Contact: a quiet envelope icon instead of a button */
.cta-header { display: flex; color: var(--muted); }
.cta-header:hover, .cta-header:focus-visible { color: var(--text); }

.button {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: var(--accent);
  color: var(--bg);
  font: inherit;
  font-size: 15px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { background: var(--bg); color: var(--accent); }
.button-secondary { background: var(--bg); color: var(--accent); }

@media (max-width: 600px) {
  .site-header { padding-top: 20px; padding-bottom: 24px; }
  .logo-tagline { display: none; }
  .main-nav { order: 3; width: 100%; margin-left: 0; }
  .header-actions { margin-left: auto; }
}

/* --- Main ----------------------------------------------------------------- */

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--side);
}

.page-title {
  margin: 0 0 8px;
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 700;
  line-height: 1.2;
}

/* Gallery: project covers – full width, stacked; year and title fade in on hover (as on the old site) */
.covers {
  display: grid;
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.page-gallery .page-title { margin-bottom: 24px; }
.cover a { position: relative; display: block; text-decoration: none; color: #fff; }
.cover picture { display: block; height: clamp(270px, 62.5vw, 900px); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-details {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 10%;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.cover a:hover .cover-details,
.cover a:focus-visible .cover-details { opacity: 1; }
.cover-year { font-size: 14px; line-height: 20px; padding-bottom: 5px; }
.cover-title { font-size: clamp(32px, 5vw, 70px); line-height: 1.05; font-weight: 400; }
/* No hover on touch screens: keep year and title visible on a lighter veil */
@media (hover: none) {
  .cover-details { opacity: 1; background: rgba(0, 0, 0, 0.35); }
}

/* Project: header and justified grid */
.project-header { margin-bottom: 32px; max-width: 60ch; }
.project-meta { margin: 0; color: var(--muted); font-size: 14px; }
.project-description { margin: 12px 0 0; }

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}
.grid::after { content: ""; flex-grow: 1000000; } /* keeps the last row from stretching */
.grid-item {
  position: relative;
  overflow: hidden;
  margin: 0;
  flex-grow: calc(var(--ar) * 100);
  flex-basis: calc(var(--ar) * var(--row));
  min-width: 0;
}
.grid-link { display: block; }
.grid-item picture { display: block; aspect-ratio: var(--ar); }
.grid-item img { width: 100%; height: 100%; object-fit: cover; }
/* Title overlays the bottom edge and slides in on hover (as on the old site) */
.grid-item figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 15px 15px 10px;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.4) 20px, rgba(0, 0, 0, 0.5));
  color: #fff;
  font-size: 14px;
  line-height: 17px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 150ms ease-in-out, transform 150ms 50ms ease-out;
}
.grid-item:hover figcaption,
.grid-item:focus-within figcaption { opacity: 1; transform: none; }
/* No hover on touch screens: titles only in the lightbox */
@media (hover: none) {
  .grid-item figcaption { display: none; }
}

@media (max-width: 1000px) { :root { --row: 240px; } }
@media (max-width: 600px) {
  .grid-item { flex-basis: 100%; }
}

/* Lightbox */
.lightbox {
  width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: rgba(255, 255, 255, 0.97);
  color: var(--text);
}
.lightbox:focus { outline: none; }
.lightbox::backdrop { background: rgba(255, 255, 255, 0.97); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(100vw - 120px);
}
.lightbox-figure img {
  max-width: calc(100vw - 120px);
  max-height: calc(100dvh - 140px);
  width: auto; height: auto;
  object-fit: contain;
}
.lightbox figcaption { margin-top: 12px; text-align: center; font-size: 14px; max-width: 70ch; }
.lightbox-title { display: block; font-weight: 700; }
.lightbox-caption { display: block; }
.lightbox-exif { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.lightbox button {
  position: absolute;
  border: 0; background: none; color: var(--text);
  font: 300 44px/1 var(--font);
  width: 56px; height: 56px;
  cursor: pointer;
}
.lightbox-close { top: 12px; right: 12px; }
.lightbox-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lightbox button:disabled { visibility: hidden; }

@media (max-width: 600px) {
  .lightbox-figure, .lightbox-figure img { max-width: 100vw; }
  .lightbox-prev, .lightbox-next { top: auto; bottom: 8px; transform: none; }
}

/* Text pages, forms */
.text { max-width: 640px; padding-bottom: 32px; }
.text h2 { margin: 32px 0 8px; font-size: 18px; }
address { font-style: normal; }
.contact-details { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }

.contact-form { margin-top: 24px; }
.field { margin-bottom: 20px; }
.field label { display: block; margin-bottom: 4px; font-weight: 600; }
.required { font-weight: 400; color: var(--muted); font-size: 14px; }
.field input, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #949494;
  border-radius: 2px;
  font: inherit;
  background: var(--bg);
  color: var(--text);
}
.field [aria-invalid="true"] { border-color: var(--error); border-width: 2px; }
.field-error { margin: 4px 0 0; color: var(--error); font-size: 14px; }
.error-summary { margin-bottom: 24px; padding: 12px 16px; border: 2px solid var(--error); }
.error-summary p { margin: 0 0 4px; font-weight: 600; }
.error-summary ul { margin: 0; padding-left: 20px; }
.error-summary a { color: var(--error); }
.form-note { font-size: 14px; color: var(--muted); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.not-found-code { margin: 0; font-size: 72px; font-weight: 700; line-height: 1; color: var(--line); }
.not-found .button { margin: 0 8px 8px 0; }

/* --- Footer --------------------------------------------------------------- */

.site-footer {
  width: min(var(--max) - 2 * var(--side), 100% - 2 * var(--side));
  margin: 64px auto 0;
  padding: 24px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}
.site-footer p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0; padding: 0; list-style: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
