/* saudade.land: one full-screen photograph, a few words, a wordmark. */

:root {
  --pad: 20px;
  --ink: #fff;
  --backdrop: #0a0a0a;
  --fade: 0.45;                              /* strength of the dark fade behind the words, set per photo */
  --dur: 1000ms;
  --ease: cubic-bezier(0.7, 0, 0.2, 1);
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --weight-body: 400;
}
html[data-body="2"] { --font-body: "pacaembu", "Inter", system-ui, sans-serif; }
html[data-body="3"] { --font-body: "neue-haas-unica", "Inter", system-ui, sans-serif; --weight-body: 300; }

@media (min-width: 720px) {
  :root { --pad: 32px; }
}

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

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--backdrop);
  color: var(--ink);
}

body {
  font-family: var(--font-body);
  font-weight: var(--weight-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

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

/* ---------- the photograph ---------- */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--backdrop);
  touch-action: pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
}

.slides, .slide, .slide__inner { position: absolute; inset: 0; }

.slide {
  overflow: hidden;
  background: var(--c, #111);
  /* landscape screens use the "wide" cut, upright screens the "tall" one */
  --fx: var(--wfx, 50%); --fy: var(--wfy, 50%); --lq: var(--wlq, none);
}
@media (orientation: portrait) {
  .slide { --fx: var(--tfx, 50%); --fy: var(--tfy, 50%); --lq: var(--tlq, none); }
}
.slide.is-moving { will-change: transform, opacity; box-shadow: 0 0 80px rgba(0, 0, 0, 0.45); }
.slide.is-moving .slide__inner { will-change: transform; }

.slide__blur {
  position: absolute;
  inset: -8%;
  background-image: var(--lq);
  background-size: cover;
  background-position: var(--fx) var(--fy);
  filter: blur(28px);
}

.slide picture { position: absolute; inset: 0; }
.slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--fx) var(--fy);
  opacity: 0;
  transition: opacity 600ms ease;
  -webkit-user-drag: none;
}
.slide img.is-loaded { opacity: 1; }

/* ---------- the fade that keeps white text readable ---------- */

.scrim {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 60%;
  z-index: 2;
  pointer-events: none;
  opacity: var(--fade);
  transition: opacity var(--dur) var(--ease);
  background: linear-gradient(to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.03) 14%,
    rgba(0, 0, 0, 0.10) 28%,
    rgba(0, 0, 0, 0.22) 43%,
    rgba(0, 0, 0, 0.42) 59%,
    rgba(0, 0, 0, 0.68) 76%,
    rgba(0, 0, 0, 0.90) 91%,
    rgba(0, 0, 0, 1) 100%);
}

/* ---------- edge zones: the left and right 10% ---------- */

.edge {
  position: absolute;
  top: 0; bottom: 0;
  z-index: 3;
  width: 10%;
  min-width: 44px;
  margin: 0; padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y pinch-zoom;
}
.edge--prev {
  left: 0;
  justify-content: flex-start;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M32 22H12m8-8-8 8 8 8' stroke='%23000' stroke-opacity='.35' stroke-width='5'/%3E%3Cpath d='M32 22H12m8-8-8 8 8 8' stroke='%23fff' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E") 22 22, w-resize;
}
.edge--next {
  right: 0;
  justify-content: flex-end;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cg fill='none' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22h20m-8-8 8 8-8 8' stroke='%23000' stroke-opacity='.35' stroke-width='5'/%3E%3Cpath d='M12 22h20m-8-8 8 8-8 8' stroke='%23fff' stroke-width='2'/%3E%3C/g%3E%3C/svg%3E") 22 22, e-resize;
}
.edge:focus { outline: none; }
/* keyboard focus rings the arrow, not the whole strip */
.edge:focus-visible .edge__hint { outline: 2px solid var(--ink); outline-offset: 6px; border-radius: 50%; }

.edge__hint {
  display: block;
  width: 40px; height: 40px;
  margin: 0 calc(var(--pad) - 10px);
  opacity: 0;
  transition: opacity 500ms ease, transform 700ms var(--ease);
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.55));
}
.edge__hint svg { display: block; width: 100%; height: 100%; }
.edge--prev .edge__hint { transform: translateX(8px); }
.edge--next .edge__hint { transform: translateX(-8px); }
.stage.is-hinting .edge__hint,
.edge:focus-visible .edge__hint { opacity: 0.9; transform: none; }

/* ---------- the words ---------- */

.words {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 4;
  pointer-events: none;                       /* taps fall through to the edge zones, except on the link */
  padding:
    var(--pad)
    calc(var(--pad) + env(safe-area-inset-right))
    calc(var(--pad) + env(safe-area-inset-bottom))
    calc(var(--pad) + env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "desc desc" "email mark";
  column-gap: 16px;
  row-gap: 0;
  align-items: end;
}
.words__text { display: contents; }
.words__desc {
  grid-area: desc;
  margin: 0 0 20px;
  max-width: 34em;
  text-wrap: pretty;
}
.words__email {
  grid-area: email;
  justify-self: start;
  pointer-events: auto;
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  -webkit-user-select: text;
  user-select: text;
}
/* a whisper of shadow so the words survive a busy patch of photo */
.words__desc, .words__email { text-shadow: 0 1px 14px rgba(0, 0, 0, 0.4); }
.wordmark svg { filter: drop-shadow(0 1px 12px rgba(0, 0, 0, 0.35)); }
.words__email:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 2px; }

.wordmark {
  grid-area: mark;
  margin: 0 0 7px;                            /* sits on the email's baseline */
  font-size: 0;
  line-height: 0;
}
/* heights are the outlined shape: 23px is 28px type, 32px is 40px type */
.wordmark svg { display: block; height: 23px; width: auto; }

@media (max-width: 349px) {
  .words { grid-template-columns: 1fr; grid-template-areas: "desc" "mark" "email"; }
  .wordmark { margin-bottom: 14px; }
}
@media (min-width: 720px) {
  .words {
    grid-template-columns: minmax(0, 380px) 1fr auto;
    grid-template-areas: "desc . mark" "email . mark";
  }
  .words__desc { max-width: none; margin-bottom: 8px; }
  .wordmark svg { height: clamp(26px, 2.23vw, 44px); }   /* 32px tall at a 1440 wide screen */
}

/* ---------- people who ask for less motion get a quiet cross-fade ---------- */

@media (prefers-reduced-motion: reduce) {
  .edge__hint, .slide img, .scrim { transition-duration: 200ms; }
}

/* ---------- prototype controls (removed before launch) ---------- */

.tune {
  position: fixed;
  top: 12px; left: 12px;
  z-index: 10;
  width: 268px;
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 12px 14px 14px;
  border-radius: 10px;
  background: rgba(12, 12, 12, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: #eee;
  font: 12px/1.45 system-ui, -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}
.tune[hidden] { display: none; }
.tune h2 { margin: 0 0 8px; font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; }
.tune h2 span { font-weight: 400; opacity: 0.6; }
.tune fieldset { margin: 0 0 10px; padding: 0; border: 0; }
.tune legend { padding: 0; margin-bottom: 4px; opacity: 0.6; }
.tune .row { display: flex; flex-wrap: wrap; gap: 4px; }
.tune .row--spaced { margin-top: 6px; }
.tune button {
  font: inherit; color: inherit;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.tune button[aria-pressed="true"] { background: #fff; color: #000; border-color: #fff; }
.tune input[type="range"] { width: 100%; }
.tune .info { opacity: 0.75; word-break: break-word; }
.tune textarea {
  width: 100%; height: 64px;
  margin-top: 6px;
  font: 11px/1.4 ui-monospace, Menlo, monospace;
  color: #ddd;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  resize: vertical;
}
.tune-toggle {
  position: fixed;
  top: 10px; left: 10px;
  z-index: 9;
  padding: 5px 10px;
  border: 0; border-radius: 999px;
  background: rgba(12, 12, 12, 0.6);
  color: #fff;
  font: 12px system-ui, sans-serif;
}
.toast {
  position: fixed;
  top: 16px; left: 50%;
  z-index: 11;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(12, 12, 12, 0.8);
  color: #fff;
  font: 12px system-ui, sans-serif;
  opacity: 0;
  transition: opacity 250ms ease;
  pointer-events: none;
}
.toast.is-on { opacity: 1; }
