/* ===========================================================================
   Video Tools — /video-tools index, colour picker, aspect ratio calculator.
   Tokens from flayr.css only. The index reuses the /links tiles (website.css).
   ======================================================================== */

/* ------------------------------------------------------------ index ---- */
.website-hub-grid.tools-hub-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .website-hub-grid.tools-hub-grid { grid-template-columns: minmax(0, 1fr); } }
.website-hub-tile .tools-hub-title { font-size: var(--fs-4); line-height: 1.24; letter-spacing: -0.015em; margin-bottom: 6px; }

/* ===================================================== colour picker ==== */
/* Full bleed: no footer, the stage fills the viewport under the 52px nav.
   The body takes the colour too (set from JS) so the frosted nav is tinted. */
.tools-fullbleed .footer { display: none; }
.tools-fullbleed main { min-height: 0; }
.tools-fullbleed { overflow-x: hidden; transition: background-color .35s var(--ease); }
.tools-fullbleed.cp-live { transition-duration: .06s; }

.cp-stage {
  --cp-fg: var(--ink);
  --cp-fg-soft: rgba(13, 22, 37, .6);
  position: relative; width: 100%;
  height: calc(100vh - 52px); height: calc(100dvh - 52px); min-height: 480px;
  overflow: hidden;
  background-color: var(--teal);
  color: var(--cp-fg);
  transition: background-color .35s var(--ease), color .35s var(--ease);
}
.cp-live .cp-stage { transition-duration: .06s; }
.cp-stage.is-light { --cp-fg: #fff; --cp-fg-soft: rgba(255, 255, 255, .72); }

/* Values along the bottom, in the display type */
.cp-values { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 var(--gutter) clamp(20px, 5vh, 48px); pointer-events: none; }
.cp-title { font-size: var(--fs-sm); font-weight: 600; letter-spacing: -0.005em; color: var(--cp-fg-soft); margin: 0 0 clamp(8px, 2vh, 18px); transition: color .35s var(--ease); }
.cp-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(10px, 2.4vh, 24px) clamp(16px, 3vw, 40px); }
.cp-value {
  pointer-events: auto; display: block; min-width: 0; text-align: left;
  margin: -6px -10px; padding: 6px 10px; border: 0; border-radius: var(--r);
  background: transparent; color: inherit; cursor: copy;
  transition: background .18s var(--ease);
}
.cp-value:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.cp-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 500; letter-spacing: 0; color: var(--cp-fg-soft); margin-bottom: 2px; }
.cp-label .icon { width: 12px; height: 12px; opacity: 0; transition: opacity .18s; }
.cp-value:hover .cp-label .icon, .cp-value:focus-visible .cp-label .icon { opacity: 1; }
.cp-num {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: pre;
  font-size: clamp(26px, 2.8vw, 50px); font-weight: 650; line-height: 1.1; letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

/* Floating picker panel */
.cp-panel {
  position: absolute; z-index: 5; top: 20px; right: var(--gutter); width: 300px;
  padding: 4px 16px 16px; border-radius: var(--r-xl);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow-pop); color: var(--ink);
}
.cp-panel-head { display: flex; align-items: center; gap: 10px; height: 44px; cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
.cp-panel.is-dragging .cp-panel-head { cursor: grabbing; }
.cp-swatch { flex: none; width: 20px; height: 20px; border-radius: 6px; background: var(--teal); box-shadow: inset 0 0 0 1px rgba(13, 22, 37, .12); }
.cp-panel-title { flex: 1; font-size: var(--fs-sm); font-weight: 600; }
.cp-grip { color: var(--faint); display: grid; }
.cp-grip .icon { width: 16px; height: 16px; }
.cp-collapse .icon { transition: transform .25s var(--ease); }
.cp-panel.is-collapsed .cp-collapse .icon { transform: rotate(180deg); }
.cp-panel.is-collapsed .cp-panel-body { display: none; }
.cp-panel.is-collapsed { padding-bottom: 4px; }

.cp-field { position: relative; aspect-ratio: 1 / 1; border-radius: var(--r); cursor: crosshair; touch-action: none; margin-top: 4px; }
.cp-field canvas { width: 100%; height: 100%; border-radius: var(--r); }
.cp-hue {
  position: relative; height: 20px; margin-top: 14px; border-radius: var(--pill); cursor: pointer; touch-action: none;
  background: linear-gradient(to right, #f00 0%, #ff0 16.667%, #0f0 33.333%, #0ff 50%, #00f 66.667%, #f0f 83.333%, #f00 100%);
}
.cp-thumb {
  position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none;
  box-shadow: 0 0 0 3px #fff, 0 1px 6px rgba(13, 22, 37, .35);
}
.cp-hue .cp-thumb { top: 50%; }
.cp-field:focus-visible, .cp-hue:focus-visible { box-shadow: var(--ring); }
.cp-controls { display: flex; gap: 8px; margin-top: 14px; }
.input.cp-hex-input { flex: 1; min-width: 0; font-family: var(--mono); text-transform: uppercase; letter-spacing: .02em; }
.cp-note { font-size: var(--fs-xs); color: var(--muted); margin: 8px 0 0; }
.cp-share { margin-top: 12px; }
.cp-sample-open { margin-top: 12px; }

/* Sampler overlay: a large card over the colour stage */
.cp-sampler { position: fixed; inset: 52px 0 0; z-index: 50; display: grid; place-items: center; padding: clamp(12px, 3vw, 32px); background: rgba(13, 22, 37, .45); }
.cp-sampler[hidden] { display: none; }
.cp-sampler-card { width: min(1200px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r-xl); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
.cp-sampler-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cp-sampler-title { flex: 1; font-size: var(--fs-4); margin: 0; }
.cp-sampler-size select { min-height: 34px; }
.cp-drop { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: clamp(32px, 7vw, 80px) 20px; border-radius: var(--r-lg); background: var(--surface-2); outline: 2px dashed transparent; transition: outline-color .15s, background .15s; }
.cp-drop.is-over { outline-color: var(--teal); background: var(--mint-soft); }
.cp-drop > .icon { width: 36px; height: 36px; color: var(--teal-ink); }
.cp-drop-title { font-weight: 600; margin: 0; }
.cp-drop-sub { color: var(--muted); font-size: var(--fs-sm); max-width: 520px; margin: 0 0 8px; }
.cp-drop kbd { font: inherit; font-size: .85em; padding: 1px 6px; border-radius: 6px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--hairline); }
.cp-canvas-wrap { position: relative; min-height: 0; flex: 1; display: grid; place-items: center; overflow: hidden; border-radius: var(--r-lg); background: var(--surface-2); }
.cp-canvas-wrap[hidden] { display: none; }
.cp-sample-canvas { display: block; max-width: 100%; max-height: calc(100dvh - 52px - 220px); cursor: crosshair; touch-action: none; }
.cp-loupe { position: absolute; left: 0; top: 0; width: 132px; height: 132px; border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 3px #fff, 0 6px 24px rgba(13, 22, 37, .35); image-rendering: pixelated; }
.cp-loupe[hidden] { display: none; }
.cp-video-bar { display: flex; align-items: center; gap: 10px; }
.cp-video-bar[hidden] { display: none; }
.cp-scrub { flex: 1; accent-color: var(--teal); }
.cp-video-time { font-variant-numeric: tabular-nums; font-size: var(--fs-sm); color: var(--muted); min-width: 4.5em; text-align: right; }
.cp-sampler-hint { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
@media (max-width: 700px) {
  .cp-sampler { padding: 8px; }
  .cp-sampler-card { padding: 12px; }
  .cp-sampler-title { flex-basis: 100%; }
  .cp-sampler-size { flex: 1; }
  .cp-sampler-size select { width: 100%; }
  .cp-sample-canvas { max-height: calc(100dvh - 52px - 230px); }
}

/* Phones: values at the top, the picker becomes a bottom sheet */
@media (max-width: 700px) {
  .cp-values { top: 0; bottom: auto; padding-top: 18px; }
  .cp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
  .cp-value-ycbcr { grid-column: 1 / -1; }
  .cp-num { font-size: clamp(16px, 4.8vw, 26px); }
  .cp-panel {
    top: auto !important; left: 0 !important; right: 0; bottom: 0; width: auto;
    border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 0 16px calc(14px + env(safe-area-inset-bottom));
  }
  .cp-panel-head { cursor: default; }
  .cp-grip { display: none; }
  .cp-field { aspect-ratio: auto; height: clamp(110px, 22vh, 180px); }
  .cp-hue { margin-top: 12px; }
  .cp-controls { margin-top: 12px; }
  .cp-share { margin-top: 10px; }
}
@media (max-width: 700px) and (max-height: 640px) {
  .cp-field { height: 96px; }
  .cp-share { display: none; }
}

/* ============================================= aspect ratio calculator == */
.tools-hero { padding-bottom: clamp(24px, 4vw, 40px); }
.tools-hero .eyebrow:hover { text-decoration: none; opacity: .8; }
.tools-section { padding-top: 0; }

.ar-layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 12px; }
.ar-inputs { display: flex; flex-direction: column; gap: 18px; }
.ar-dims { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: end; }
.ar-swap { margin-bottom: 8px; }
.input.ar-num { min-height: 52px; font-size: var(--fs-4); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.ar-hint { font-size: var(--fs-xs); color: var(--muted); margin: -6px 0 0; }
.ar-result { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-top: auto; }
.ar-result-ratio { font-size: var(--fs-1); font-weight: 650; line-height: 1; letter-spacing: -0.035em; color: var(--ink); font-variant-numeric: tabular-nums; }
.ar-result-dec { font-size: var(--fs-4); color: var(--muted); font-variant-numeric: tabular-nums; }
.ar-share { align-self: flex-start; }

.ar-preview-card { display: flex; flex-direction: column; }
.ar-stage { flex: 1; display: grid; place-items: center; min-height: 300px; height: clamp(300px, 34vw, 440px); padding: 24px; background: var(--surface-2); border-radius: var(--r-lg); overflow: hidden; }
.ar-shape {
  display: grid; place-items: center; width: 160px; height: 90px; min-width: 6px; min-height: 6px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%);
  border-radius: var(--r-sm);
  transition: width .45s var(--ease), height .45s var(--ease);
}
.ar-shape-label { padding: 4px 12px; border-radius: var(--pill); background: rgba(255, 255, 255, .88); color: var(--ink); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ar-preview-caption { text-align: center; margin: 14px 0 0; font-size: var(--fs-sm); color: var(--muted); }

.ar-h2 { margin: clamp(40px, 6vw, 64px) 0 20px; }
.ar-stats { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ar-stats .stat-value { overflow-wrap: anywhere; }
.ar-uses { margin-top: 12px; }
.ar-uses h3, .ar-two h3 { font-size: var(--fs-4); margin-bottom: 8px; }
.ar-uses p { margin: 0; color: var(--muted); }
.ar-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.ar-table td, .ar-table th { padding-left: 10px; padding-right: 10px; }
.ar-table td { font-variant-numeric: tabular-nums; }
.ar-table tr.is-current td { background: var(--mint-soft); color: var(--ink); font-weight: 600; }
.ar-small { font-size: var(--fs-xs); color: var(--faint); margin: 12px 0 0; }
.ar-frame { display: grid; place-items: center; aspect-ratio: 16 / 9; margin: 6px 0 16px; background: var(--ink); border-radius: var(--r); overflow: hidden; }
.ar-frame-inner { width: 100%; height: 100%; background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%); transition: width .45s var(--ease), height .45s var(--ease); }
.ar-two p { margin: 0; color: var(--text); }

@media (max-width: 860px) {
  .ar-layout, .ar-two { grid-template-columns: minmax(0, 1fr); }
  .ar-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ar-stage { height: 280px; min-height: 0; }
}
@media (max-width: 359px) {
  .ar-stats { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .cp-stage, .tools-fullbleed, .ar-shape, .ar-frame-inner { transition: none; }
}
