@font-face {
  font-family: "Poppins";
  src: url("/fonts/Poppins-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/Poppins-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("/fonts/Poppins-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

:root {
  --ink: #161616;
  --ink-muted: #5d5d62;
  --ink-faint: #737378;
  --ink-hover: #34343a;
  --line: #e4e4e1;
  --line-strong: #c8c8c4;
  /* The field's edge must read at 3:1 against white (WCAG non-text contrast). */
  --field-line: #8b8b86;
  --field-line-hover: #5d5d62;
  --paper: #ffffff;
  --paper-sunk: #f3f3f1;
  --plan: #e2e2de;
  --plan-shade: #d3d3ce;
  --plan-onshade: #e9e9e5;
  --error: #c42b1c;
  --on-ink-muted: #b4b4ba;
  --radius: 6px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--line-strong) var(--paper);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 "Poppins", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--ink);
  color: #fff;
}

img,
svg {
  display: block;
}

a {
  color: inherit;
  text-underline-offset: 0.22em;
  text-decoration-thickness: 1px;
}

button {
  font: inherit;
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

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

/* Masthead: an ink bar, which the Orihost wordmark (white "ori") needs. */

.masthead {
  background: var(--ink);
}

.masthead__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1180px;
  height: 64px;
  margin: 0 auto;
  padding: 0 24px;
}

.masthead :focus-visible {
  outline-color: #fff;
}

.brand {
  border-radius: 2px;
}

.brand img {
  width: auto;
  height: 22px;
}

.masthead__tool {
  padding-left: 16px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--on-ink-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 20px;
}

/* Page */

.page {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.intro h1 {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.intro p {
  max-width: 80ch;
  margin: 10px 0 0;
  color: var(--ink-muted);
  text-wrap: pretty;
}

/* Link form */

.request {
  max-width: 780px;
  margin-top: 32px;
}

.request label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 500;
}

.request__row {
  display: flex;
  gap: 12px;
}

.request input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  caret-color: var(--ink);
  transition: border-color 150ms, box-shadow 150ms;
}

.request input::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

.request input:hover {
  border-color: var(--field-line-hover);
}

.request input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(22, 22, 22, 0.1);
}

.request input[aria-invalid="true"] {
  border-color: var(--error);
}

.request input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(196, 43, 28, 0.16);
}

.request__msg {
  min-height: 1.55em;
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.request__msg.is-error {
  color: var(--error);
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms, color 150ms;
}

.button--primary {
  height: 52px;
  padding: 0 26px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9375rem;
}

.button--primary:hover {
  background: var(--ink-hover);
}

.button--primary:active {
  background: #000;
}

.button--primary:disabled {
  background: var(--ink);
  opacity: 0.55;
  cursor: progress;
}

.text-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color 150ms;
}

.text-action:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* Article */

.article {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 16px;
}

.article__title {
  max-width: 46ch;
  margin: 0;
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.4;
  text-wrap: balance;
}

.article__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  margin-top: 12px;
  font-size: 0.875rem;
}

/* The site the link belongs to, marked with that site's own colour. */
.article__site {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.article__swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--site-color, var(--ink));
}

.article__category {
  color: var(--ink-muted);
}

.article__copy.is-done {
  color: var(--ink);
}

/* Results from an earlier link, after a new link was rejected. */
.article,
.sheet {
  transition: opacity 200ms var(--ease-out);
}

.article.is-stale,
.sheet.is-stale {
  opacity: 0.45;
}

/* Preview sheet: column widths follow each format's aspect ratio, so the
   three frames line up at one height. */

.sheet {
  --plan-brand: transparent;
  display: grid;
  grid-template-columns: 4fr 5fr 2.8125fr;
  align-items: end;
  gap: 32px;
  margin-top: 32px;
}

.article[hidden] + .sheet {
  margin-top: 48px;
}

.shot {
  min-width: 0;
  margin: 0;
}

.frame {
  position: relative;
  overflow: hidden;
  container-type: inline-size;
  border-radius: 4px;
  background: var(--paper-sunk);
  box-shadow: inset 0 0 0 1px rgba(22, 22, 22, 0.06);
}

.shot--instagram .frame {
  aspect-ratio: 4 / 5;
}

.shot--facebook .frame {
  aspect-ratio: 1;
}

.shot--story .frame {
  aspect-ratio: 9 / 16;
}

/* Outline of the recognised site's card, drawn from that site's own
   measurements (1080px wide = 100cqw), shown until the image arrives. */

.plan {
  position: absolute;
  inset: 0;
  transition: opacity 240ms var(--ease-out);
}

.plan__rect {
  position: absolute;
  border-radius: 0.4cqw;
  animation: plan-in 240ms var(--ease-out);
}

.plan__rect--line {
  background: var(--plan);
}

.plan__rect--brand {
  background: var(--plan-brand);
}

.plan__rect--shade {
  border-radius: 0;
  background: var(--plan-shade);
}

.plan__rect--onshade {
  background: var(--plan-onshade);
}

@keyframes plan-in {
  from {
    opacity: 0;
  }
}

/* The finished image comes down over its outline, top to bottom, like a
   proof coming off the press. */
.frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 520ms var(--ease-out);
}

.shot.is-ready .frame img {
  clip-path: inset(0);
}

.shot.is-ready .plan {
  opacity: 0;
  transition-delay: 300ms;
}

.shot.is-error .plan {
  opacity: 0.35;
}

/* Loading: a light sweep across the outline. */

.shot.is-loading .frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 25%, rgba(255, 255, 255, 0.7) 50%, transparent 75%);
  transform: translateX(-100%);
  animation: sweep 1.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes sweep {
  to {
    transform: translateX(100%);
  }
}

/* Inset by 1px so the frame's own hairline stays visible around it. */
.frame__error {
  display: none;
  position: absolute;
  right: 1px;
  bottom: 1px;
  left: 1px;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 15px 15px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 4px 4px;
  background: var(--paper);
}

.frame__error p {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.shot.is-error .frame__error {
  display: flex;
}

.shot__retry {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

.shot__retry:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}

/* Name, size and download sit above each image. */
.shot figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.shot__name {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
}

.shot__size {
  display: block;
  color: var(--ink-muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.download {
  flex-shrink: 0;
  height: 38px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Not available until the image exists: flat and quiet, no border. */
.download:not([href]) {
  border-color: transparent;
  background: var(--paper-sunk);
  color: #a3a39f;
  cursor: not-allowed;
}

.download[href]:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

/* Footer */

.footer {
  border-top: 1px solid var(--line);
}

.footer__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px;
  color: var(--ink-muted);
  font-size: 0.8125rem;
}

.footer a {
  color: var(--ink);
}

/* Small screens: one column, the story kept narrower so it doesn't
   take three screens of scrolling. */

@media (max-width: 760px) {
  .masthead__inner {
    height: 56px;
    padding: 0 16px;
  }

  .brand img {
    height: 19px;
  }

  .masthead__tool {
    font-size: 0.875rem;
  }

  .page {
    padding: 32px 16px 56px;
  }

  .intro h1 {
    font-size: 1.5rem;
  }

  .intro p {
    font-size: 0.9375rem;
  }

  .request {
    margin-top: 28px;
  }

  .request__row {
    flex-direction: column;
  }

  .request input {
    flex: none;
  }

  /* Before a link is given, the three frames sit side by side as
     thumbnails; once there are results they stack at full size. */
  .sheet {
    gap: 12px;
  }

  .sheet:not(.is-active) figcaption {
    margin-bottom: 8px;
  }

  .sheet:not(.is-active) .shot__name {
    font-size: 0.8125rem;
  }

  .sheet:not(.is-active) .shot__size {
    font-size: 0.75rem;
  }

  .sheet:not(.is-active) .download {
    display: none;
  }

  .sheet.is-active {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  /* Only the frame narrows; its caption keeps the full width so all three
     download buttons share one right edge. */
  .sheet.is-active .shot--story .frame {
    width: 72%;
  }

  .footer__inner {
    padding: 18px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shot.is-loading .frame::after {
    animation: none;
    transform: none;
    background: rgba(255, 255, 255, 0.35);
  }

  .plan,
  .frame img {
    transition: none;
  }

  .plan__rect {
    animation: none;
  }

  .frame img {
    clip-path: none;
  }
}
