/* ==========================================================================
   K04 — Layout, Grids & Image Ratios (kit/layout.html)
   Breakpoint cards, grid-break diagrams, preset grid modes, image ratios
   with focal points, spacing scale, geometry and the 12-column overlay.
   ========================================================================== */

/* ---- Shared helpers --------------------------------------------------- */

/* Striped image stand-in without the .ph frame (padding, radius, label) */
.stripes {
  background: repeating-linear-gradient(135deg, var(--ph) 0 10px, var(--ph-stripe) 10px 11px);
  filter: var(--img-filter);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 16px;
}

.layout-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.layout-card__title {
  font-weight: 600;
}

.layout-card__text {
  font-size: 15px;
  color: var(--muted);
  text-wrap: pretty;
}

/* ---- 01 Grid ---------------------------------------------------------- */
.grid-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin: -8px 0 20px;
}

.grid-toggle {
  padding: 10px 18px;
}

.bp-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.bp-card__width {
  font-family: var(--f-display);
  font-weight: var(--d-weight);
  text-transform: var(--d-case);
  letter-spacing: var(--d-track);
  font-size: 32px;
  line-height: 1;
}

/* Column count comes from style="--cols: 12" */
.bp-columns {
  display: grid;
  grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr));
  gap: 6px;
  height: 120px;
}

.bp-columns--tight {
  gap: 5px;
}

.bp-columns > span {
  background: var(--accent);
  opacity: .14;
}

.bp-card__spec {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--muted);
}

/* ---- 02 Grid breaks ---------------------------------------------------
   12 × 6 diagram with faint column rules; blocks use --col / --row. */
.break-diagram {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 4px;
  height: 150px;
  background: repeating-linear-gradient(90deg, transparent 0 calc((100% - 44px) / 12), var(--line) 0 calc((100% - 44px) / 12 + 4px));
}

.break-diagram__img,
.break-diagram__text {
  grid-column: var(--col);
  grid-row: var(--row);
}

.break-diagram__img {
  background: repeating-linear-gradient(135deg, var(--ph) 0 10px, var(--ph-stripe) 10px 11px);
  filter: var(--img-filter);
}

.break-diagram__text {
  background: var(--ink);
  opacity: .85;
}

/* ---- 03 Grid modes ---------------------------------------------------- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 16px;
}

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--f-body);
}

.mode-card__preview {
  height: 140px;
}

.mode-card__title {
  font-size: 16px;
  font-weight: 600;
}

.mode-card__text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

/* Editorial: asymmetric 7/5 split */
.mode-editorial {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 8px;
  height: 100%;
}

.mode-editorial__text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mode-editorial__head {
  height: 10px;
  background: var(--ink);
}

.mode-editorial__line {
  width: var(--w);
  height: 6px;
  background: var(--muted);
}

.mode-editorial__img {
  flex: 1;
}

/* Gallery: framed works, centred */
.mode-gallery {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  height: 100%;
}

.mode-gallery__work {
  width: var(--w);
  aspect-ratio: 4/5;
  outline: 8px solid var(--surface);
}

/* Raw: ruled 4 × 2 cells, no gutter */
.mode-raw {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  height: 100%;
  border: 1px solid var(--ink);
}

.mode-raw > span {
  border: 1px solid var(--ink);
}

/* Playful: tilted, overlapping frames plus a sticker */
.mode-playful {
  position: relative;
  height: 100%;
}

.mode-playful__frame {
  position: absolute;
  border-radius: var(--radius);
}

.mode-playful__frame--back {
  left: 6%;
  top: 10%;
  width: 40%;
  height: 70%;
  transform: rotate(-4deg);
}

.mode-playful__frame--front {
  left: 38%;
  top: 24%;
  width: 34%;
  height: 62%;
  transform: rotate(3deg);
}

.mode-playful__sticker {
  position: absolute;
  right: 8%;
  top: 8%;
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent);
}

/* Cinematic: letterboxed frame on black */
.mode-cinematic {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  height: 100%;
  padding: 10px 0;
  background: #000;
}

.mode-cinematic__frame {
  aspect-ratio: 2.39/1;
}

.mode-cinematic__title {
  width: 40%;
  height: 6px;
  margin-left: 8px;
  background: var(--ink);
}

/* ---- 04 Image ratios -------------------------------------------------- */
.ratio-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.ratio {
  flex: 1 1 130px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ratio--wide {
  flex-basis: 200px;
}

.ratio--wider {
  flex-basis: 260px;
}

.ratio__name {
  font-family: var(--f-display);
  font-weight: var(--d-weight);
  text-transform: var(--d-case);
  letter-spacing: var(--d-track);
  font-size: 24px;
  line-height: 1;
}

.ratio__use {
  font-size: 14px;
  color: var(--muted);
}

/* Focal point / art direction */
.focal-label {
  margin-top: 48px;
  margin-bottom: 14px;
}

.focal-row {
  display: grid;
  grid-template-columns: minmax(0, 2.39fr) minmax(0, 1.78fr) minmax(0, .8fr);
  gap: 16px;
  align-items: end;
}

.focal {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.focal__frame {
  position: relative;
  aspect-ratio: var(--ratio);
  overflow: hidden;
}

/* Crosshair: 26 px ring centred on (--x, --y) plus two 44 px hairlines.
   The pseudo-elements are offset from the ring's inner box (26 − 2 × 2 border = 22 px). */
.focal__point {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.focal__point::before,
.focal__point::after {
  content: "";
  position: absolute;
  background: var(--accent);
}

.focal__point::before {
  left: -11px;
  top: 11px;
  width: 44px;
  height: 1px;
}

.focal__point::after {
  left: 11px;
  top: -11px;
  width: 1px;
  height: 44px;
}

.focal__caption,
.focal-note {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--muted);
}

.focal-note {
  margin-top: 14px;
}

/* ---- 05 Spacing ------------------------------------------------------- */
.space-list {
  display: flex;
  flex-direction: column;
}

.space-row {
  display: grid;
  grid-template-columns: 90px 70px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.space-row__token,
.space-row__px {
  font-family: var(--f-mono);
  font-size: 13px;
}

.space-row__px {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Bar width comes from style="--w: 48px" */
.space-row__bar {
  width: min(100%, var(--w));
  height: 12px;
  background: var(--ink);
}

/* ---- 06 Geometry ------------------------------------------------------ */
.geo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 28px 16px;
}

.geo {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.geo__title {
  font-weight: 600;
}

.geo__text {
  font-size: 14px;
  color: var(--muted);
}

.geo__swatch {
  height: 120px;
}

.geo__swatch--square {
  border: 1px solid var(--ink);
}

.geo__swatch--soft {
  border: 1px solid var(--ink);
  border-radius: 14px;
}

.geo__swatch--hairlines {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.geo__swatch--hairlines > span {
  height: 1px;
  background: var(--ink);
}

.geo__swatch--hairlines > .geo__hairline--light {
  background: var(--line);
}

.geo__swatch--crop {
  position: relative;
  margin: 0 22px;
}

.crop-mark {
  position: absolute;
  background: var(--ink);
}

.crop-mark--top-h    { top: -1px;     left: -22px;   width: 14px; height: 1px; }
.crop-mark--top-v    { top: -22px;    left: -1px;    width: 1px;  height: 14px; }
.crop-mark--bottom-h { bottom: -1px;  right: -22px;  width: 14px; height: 1px; }
.crop-mark--bottom-v { bottom: -22px; right: -1px;   width: 1px;  height: 14px; }

.geo__swatch--grain {
  border: 1px solid var(--line);
  background-color: var(--canvas);
  background-image:
    radial-gradient(rgba(0, 0, 0, .07) 1px, transparent 1.2px),
    radial-gradient(rgba(0, 0, 0, .05) 1px, transparent 1.2px);
  background-size: 5px 5px, 7px 7px;
  background-position: 0 0, 2px 3px;
}

/* ---- 12-column overlay ------------------------------------------------ */
.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  justify-content: center;
  padding: 0 40px;
  pointer-events: none;
}

.grid-overlay__cols {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 24px;
  width: 100%;
  max-width: 1360px;
}

.grid-overlay__cols > span {
  border-left: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  background: var(--accent);
  opacity: .08;
}
