/* Walls. Dark, immersive, art first: the gallery is the wallpapers, and the interface gets out of
   the way. Everything floats over the grid rather than boxing it in. */

:root {
  --ink: #0A0A0A;
  --raise: #141414;
  --line: #262626;
  --text: #F5F5F5;
  --dim: #9A9A9A;
  --red: #A50E19;
  --gap: 10px;
  --radius: 18px;
  /* The notch and the home indicator. viewport-fit=cover means we must handle these ourselves. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  /* Room for the floating bar and chips, which sit over the top of the grid. */
  padding-top: calc(var(--safe-t) + 126px);
  padding-bottom: calc(var(--safe-b) + 24px);
}

/* Tapping should never flash a grey box or select the label underneath. */
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
.card, .chips button, .icon { -webkit-user-select: none; user-select: none; }

/* ---- the floating top bar ---------------------------------------------- */

.top {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(var(--safe-t) + 12px) 16px 10px;
  /* The blur is what keeps the bar legible over whatever art scrolls under it. */
  background: rgba(10,10,10,0.82);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand .by {
  margin: 1px 0 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  cursor: pointer;
}
.icon svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: var(--text);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon:active { background: rgba(255,255,255,0.16); }
.icon.ghost { background: rgba(0,0,0,0.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* ---- collection chips --------------------------------------------------- */

.chips {
  position: fixed;
  top: calc(var(--safe-t) + 72px);
  left: 0; right: 0;
  z-index: 29;
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  background: linear-gradient(to bottom, rgba(10,10,10,0.82) 55%, rgba(10,10,10,0));
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  overflow-x: auto;
  scrollbar-width: none;
  /* Horizontal chips must not drag the page sideways. */
  overscroll-behavior-x: contain;
}
.chips::-webkit-scrollbar { display: none; }

.chips button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 15px;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.09);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.chips button[aria-pressed="true"] { background: var(--red); color: #fff; }
.chips .np { font-size: 11.5px; font-weight: 500; opacity: 0.75; }

/* ---- the grid ----------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
  padding: 0 var(--gap);
}

/* No card chrome: the wallpaper is the card. Only the name sits on top of it. */
.card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 9 / 19.5;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--raise);
  cursor: pointer;
  transition: transform 160ms cubic-bezier(0.2, 0, 0.2, 1);
}
.card:active { transform: scale(0.97); }

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 26px 12px 11px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  /* The art runs under the label, so it needs its own shadow to stay readable. */
  background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0));
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.card .np { font-size: 11px; font-weight: 500; opacity: 0.82; }

.empty {
  grid-column: 1 / -1;
  padding: 48px 16px;
  text-align: center;
  color: var(--dim);
}

/* ---- the viewer --------------------------------------------------------- */

.viewer, .info {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--ink);
  color: var(--text);
  overflow: hidden;
}
.viewer::backdrop, .info::backdrop { background: rgba(0,0,0,0.85); }

.viewer .full {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Darkens the bottom so the sheet's text holds against a bright wallpaper. */
.viewer .scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.25) 32%, rgba(0,0,0,0) 56%);
  pointer-events: none;
}

.back {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  left: 14px;
  z-index: 2;
}

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 10px 20px calc(var(--safe-b) + 22px);
  text-align: center;
}

.grip {
  width: 38px;
  height: 4px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.3);
}

.sheet .meta {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sheet .np { font-size: 14px; font-weight: 500; opacity: 0.8; }
.sheet .dim { margin: 3px 0 16px; font-size: 12px; color: var(--dim); }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 340px;
  min-height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--text);
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease;
}
.primary svg { width: 19px; height: 19px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.primary:active { transform: scale(0.97); }
.primary:disabled { opacity: 0.55; }

.note { min-height: 18px; margin: 12px 0 0; font-size: 12.5px; color: var(--dim); }

/* ---- about -------------------------------------------------------------- */

.info .sheet {
  position: absolute;
  bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--raise);
  text-align: left;
  padding: 10px 22px calc(var(--safe-b) + 24px);
}
.info h2 { margin: 6px 0 10px; font-size: 20px; }
.info p { margin: 0 0 12px; font-size: 14px; color: #CFCFCF; }
.info a { color: var(--text); }
.info .primary { margin-top: 6px; max-width: none; }

/* ---- wider screens ------------------------------------------------------ */

@media (min-width: 620px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .viewer .full { object-fit: contain; background: #000; }
}

/* Someone who asked for less motion gets none of the scale transitions. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- the welcome screen ------------------------------------------------- */

/* Shown once, on a first visit. A staggered mosaic of real wallpapers over a soft ground, so the
   first thing anyone sees is the art rather than an empty gallery loading. */
.welcome {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: calc(var(--safe-t) + 18px) 18px calc(var(--safe-b) + 30px);
  background: var(--ink);
  overflow: hidden;
}
.welcome[hidden] { display: none; }

/* The warm ground of the reference, in SNS red rather than yellow. */
.welcome::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(165,14,25,0.3), transparent 62%),
    radial-gradient(90% 50% at 10% 100%, rgba(200,146,46,0.16), transparent 70%);
  pointer-events: none;
}

.mosaic {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Staggered: one wide tile across the top, then uneven pairs, as in the reference. */
  grid-template-areas:
    "a a"
    "b c"
    "d e";
  gap: 10px;
  flex: 0 1 auto;
  min-height: 0;
  align-content: start;
  /* The mosaic yields space to the headline rather than pushing it off a short screen. */
  overflow: hidden;
}
.mosaic .tile {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  background: var(--raise);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.mosaic .tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mosaic .tile:nth-child(1) { grid-area: a; aspect-ratio: 16 / 10; }
.mosaic .tile:nth-child(2) { grid-area: b; aspect-ratio: 1 / 1; }
.mosaic .tile:nth-child(3) { grid-area: c; aspect-ratio: 1 / 1; }
.mosaic .tile:nth-child(4) { grid-area: d; aspect-ratio: 4 / 5; }
.mosaic .tile:nth-child(5) { grid-area: e; aspect-ratio: 4 / 5; }
/* The pair sits slightly low, which is what gives the stagger its rhythm. */
.mosaic .tile:nth-child(3) { transform: translateY(14px); }
.mosaic .tile:nth-child(5) { transform: translateY(-14px); }

.hello { position: relative; flex: 0 0 auto; text-align: center; }
.hello h2 {
  margin: 0 0 10px;
  font-size: clamp(23px, 6.6vw, 30px);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.02em;
}
/* The italic accent word, as in the reference. */
.hello h2 em { font-style: italic; font-weight: 500; opacity: 0.82; }
.hello p {
  margin: 0 0 18px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--dim);
}

.primary.big {
  min-height: 58px;
  max-width: none;
  font-size: 16.5px;
  background: var(--red);
  color: #fff;
  /* The arrow sits at the far end, like the chevrons in the reference. */
  justify-content: space-between;
  padding: 0 26px;
}
.primary.big svg { stroke: #fff; width: 22px; height: 22px; }

/* A short screen (a small phone in landscape) must not clip the headline. */
@media (max-height: 620px) {
  .mosaic .tile:nth-child(4), .mosaic .tile:nth-child(5) { display: none; }
  .hello h2 { font-size: 21px; }
}

/* ---- photograph credits ------------------------------------------------- */

/* The licence asks for the photographer to be named wherever the picture is used, so this sits
   with the picture in the viewer rather than only in About. */
.credit {
  margin: -8px 0 14px;
  font-size: 11.5px;
  color: var(--dim);
}
.credit a { color: #D8D8D8; }

.credits {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}
.credits li {
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--dim);
}
.credits a { color: #D8D8D8; }
.info h3 { margin: 18px 0 8px; font-size: 15px; }
