/* The photo focal point with the crops that follow it: the focal point panel of an invented media library, dark, on a
   near black page with a warm light and a fine grain. The photo, a real one (dune-crest.webp), is shown in four
   places: whole in the view, and cropped in the three frames under it. */
:root {
  --page: #0b0a0c;            /* the page */
  --panel: #151417;           /* the panel */
  --panel-low: #100f12;       /* the bottom of the panel */
  --edge: rgba(255, 255, 255, 0.075); /* its edge */
  --ink: #efedf0;             /* the words */
  --muted: #8d8992;           /* the small words */
  --accent: #ffb36b;          /* the warm accent: the active crop, the light */
  --button: #f3f1ee;          /* the button */
  --button-ink: #121014;      /* the words on the button */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* the page: a warm light behind the panel and a fine grain over everything */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
  background:
    radial-gradient(60% 50% at 50% 46%, rgba(255, 150, 90, 0.10), transparent 70%),
    radial-gradient(40% 36% at 62% 30%, rgba(170, 110, 255, 0.06), transparent 70%),
    var(--page);
}

.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .7 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.panel {
  --pad: clamp(12px, 3.6vw, 18px);
  position: relative;
  z-index: 1;
  width: min(90vw, 440px, calc((96vh - 130px) * 1.25));
  padding: var(--pad);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--panel), var(--panel-low));
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 12px 24px -12px rgba(0, 0, 0, 0.7),
    0 40px 80px -30px rgba(0, 0, 0, 0.9);
  opacity: 0;
}

/* ---------------------------------------------------------------- the head */
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: clamp(8px, 2.6vh, 12px);
}

.panel__name,
.panel__meta {
  margin: 0;
}

.panel__name {
  font-size: 13.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  letter-spacing: 0.005em;
}

.panel__meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel__sep {
  width: 1px;
  height: 9px;
  background: rgba(255, 255, 255, 0.16);
}

.panel__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}

.panel__chip svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the photo */
.view {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #3b2e28;
  cursor: crosshair;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.view__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* a soft light where the focus is, moved with the reticle */
.view__glow {
  position: absolute;
  left: 0;
  top: 0;
  width: 160px;
  height: 160px;
  margin: -80px 0 0 -80px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 236, 205, 0.32), rgba(255, 200, 150, 0.08) 55%, transparent);
  mix-blend-mode: soft-light;
  pointer-events: none;
  opacity: 0;
}

/* the thirds, only while the reticle is held */
.view__thirds {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(90deg, transparent calc(33.333% - 0.5px), rgba(255, 255, 255, 0.28) calc(33.333% - 0.5px), rgba(255, 255, 255, 0.28) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px)),
    linear-gradient(90deg, transparent calc(66.666% - 0.5px), rgba(255, 255, 255, 0.28) calc(66.666% - 0.5px), rgba(255, 255, 255, 0.28) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px)),
    linear-gradient(180deg, transparent calc(33.333% - 0.5px), rgba(255, 255, 255, 0.28) calc(33.333% - 0.5px), rgba(255, 255, 255, 0.28) calc(33.333% + 0.5px), transparent calc(33.333% + 0.5px)),
    linear-gradient(180deg, transparent calc(66.666% - 0.5px), rgba(255, 255, 255, 0.28) calc(66.666% - 0.5px), rgba(255, 255, 255, 0.28) calc(66.666% + 0.5px), transparent calc(66.666% + 0.5px));
}

/* the crop shown on the photo: what stays in, lit; the rest, under a veil */
.view__shade {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85), 0 0 0 200vmax rgba(10, 7, 12, 0.52);
  pointer-events: none;
  opacity: 0;
}

.view__shade-tag {
  position: absolute;
  left: 6px;
  top: 6px;
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #fff;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(20, 14, 20, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

/* the photo's own edge, a hair of light on top */
.view__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* the reticle: GSAP moves .mark, the face scales inside it */
.mark {
  position: absolute;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  outline: none;
  cursor: grab;
}

.mark__face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.mark__face::before {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  -webkit-backdrop-filter: blur(3px) brightness(1.15);
  backdrop-filter: blur(3px) brightness(1.15);
  opacity: var(--held, 0);
}

.mark svg {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: none;
  stroke: #fff;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.mark__ring {
  stroke-width: 1.5;
}

.mark__ticks {
  stroke-width: 1.5;
}

.mark__cross {
  stroke-width: 1.2;
  opacity: 0.9;
}

.mark:focus-visible .mark__ring {
  stroke: var(--accent);
}

/* ---------------------------------------------------------------- the crops */
.crops {
  display: flex;
  gap: 8px;
  margin-top: clamp(8px, 2.6vh, 12px);
}

.crop {
  margin: 0;
  flex: 1 1 0;
  min-width: 0;
}

.crop[data-ratio='0.8'] {
  flex-grow: 0.8;
}

.crop[data-ratio='3'] {
  flex-grow: 3;
}

.crop__frame {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #3b2e28;
  aspect-ratio: 1;
  cursor: pointer;
}

.crop[data-ratio='0.8'] .crop__frame {
  aspect-ratio: 4 / 5;
}

.crop[data-ratio='3'] .crop__frame {
  aspect-ratio: 3 / 1;
}

/* the frame's edge: 1px of light, warm when its crop is the one on the photo */
.crop__frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: box-shadow 0.35s ease;
}

.crop.is-on .crop__frame::after {
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.crop__img {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  max-width: none;
  pointer-events: none;
}

.crop__cap {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: 5px;
  font-size: 10.5px;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  transition: color 0.35s ease;
}

.crop__r {
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.crop.is-on .crop__cap {
  color: var(--ink);
}

/* ---------------------------------------------------------------- the foot */
.panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: clamp(10px, 2.8vh, 14px);
}

.panel__pos {
  margin: 0;
  display: flex;
  align-items: baseline;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.panel__axis {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 5px;
}

.panel__axis + .panel__num {
  display: inline-block;
  min-width: 2ch;
  text-align: right;
}

.panel__pc {
  color: var(--muted);
  margin-right: 12px;
}

.panel__pc:last-child {
  margin-right: 0;
}

.save {
  flex: none;
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff, var(--button));
  color: var(--button-ink);
  font: inherit;
  cursor: pointer;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12), 0 6px 16px -8px rgba(255, 180, 110, 0.45);
  -webkit-tap-highlight-color: transparent;
}

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

.save__face {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.save__words {
  font-size: 13px;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

@media (hover: hover) {
  .save:hover .save__words {
    font-variation-settings: 'wdth' 112;
  }
}

.save__icon {
  width: 0;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.save__check {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
