/* OF LAYOUT — the two things Outer Fields builds: the site page and the instrument.
   Needs of-tokens.css, of-base.css, of-matter.css, of-components.css. */

/* ── Site ───────────────────────────────────────────────────────────── */
.of-site-header { position: absolute; inset: 0 0 auto; z-index: var(--of-z-header); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--of-s2) var(--of-s5); padding: var(--of-s4) var(--of-gutter); }
.of-logo { border: 0; font-size: 1.5rem; }
.of-page { width: min(100%, var(--of-page)); margin-inline: auto; padding: var(--of-s7) var(--of-gutter); }

/* a thing Outer Fields makes, the way a pouch shows it: the photograph, the name, the line under it */
.of-pouches { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: var(--of-s2); }
.of-pouch { display: grid; align-content: end; justify-items: center; aspect-ratio: 1; padding: var(--of-s5); border: 0; }
.of-pouch .of-cover__name { font-size: clamp(2rem, 5vw, 3.5rem); }
.of-pouch .of-cover__sub { font-size: 0.5625rem; padding-top: var(--of-s2); }

/* ── Instrument ─────────────────────────────────────────────────────────
   A device and a Data Fields app are the same object. The matter fills it. Everything
   stands on one axis: the mark on top, the field under it, the name at the foot. The
   controls are two columns that mirror each other: on the left what always sounds and
   what is let through, on the right the note a moment becomes.

     head     what it says of itself | mark | how it listens
     left     column | field | column    right
     time     the trace, the hours
     foot     play | name | reading                                              */
.of-instrument {
  display: grid; row-gap: var(--of-s5); column-gap: var(--of-s6); padding: var(--of-s5) var(--of-gutter) var(--of-s6);
  grid-template: "headl mark headr" auto "left field right" minmax(0, 1fr) "time time time" auto "footl foot footr" auto / var(--of-col) minmax(0, 1fr) var(--of-col);
}
.of-instrument__headl { grid-area: headl; align-self: start; }
.of-instrument__mark  { grid-area: mark; justify-self: center; }
.of-instrument__headr { grid-area: headr; align-self: start; }
.of-instrument__col   { display: grid; align-content: start; row-gap: var(--of-s4); min-width: 0; }
.of-instrument__col--l { grid-area: left; }
.of-instrument__col--r { grid-area: right; }
.of-instrument__field { grid-area: field; }
.of-instrument__time  { grid-area: time; }
.of-instrument__footl { grid-area: footl; align-self: end; }
.of-instrument__foot  { grid-area: foot; justify-self: center; align-self: end; }
.of-instrument__footr { grid-area: footr; align-self: end; }

/* the field: a frame of hairs open at the top, hanging from the mark (Grotta). Its sides stop
   before the corners of the top, so the photograph runs into it */
.of-field { position: relative; min-height: 420px; border: 0 solid var(--of-edge); border-width: 0 var(--of-hair) var(--of-hair); min-width: 0; }
.of-field > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.of-field > .of-read { position: absolute; left: var(--of-s4); bottom: var(--of-s4); pointer-events: none; }
.of-field > .of-read--r { left: auto; right: var(--of-s4); text-align: right; justify-items: end; }
.of-field__scale { position: absolute; left: 0; right: 0; bottom: calc(-1 * var(--of-s2)); transform: translateY(100%); display: flex; justify-content: space-between; font-size: var(--of-fs-label); font-weight: var(--of-w-regular); line-height: 1; color: var(--of-ink-2); }

/* time: the sound drawn as it is made. The bar that listens crosses it */
.of-trace { position: relative; height: 72px; touch-action: pan-y; cursor: ew-resize; }
.of-trace > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.of-trace > time { position: absolute; top: 0; transform: translateX(-50%); padding: 0 var(--of-s1); font-size: var(--of-fs-value); font-weight: var(--of-w-bold); line-height: 1; white-space: nowrap; pointer-events: none; }

/* a column divides its groups with short hairs, pushed to its outer side, like the devices */
.of-rule { width: var(--of-short); height: var(--of-hair); background: var(--of-edge); }
.of-instrument__col--r .of-rule { justify-self: end; }
.of-group { display: grid; row-gap: var(--of-s3); min-width: 0; }
.of-group--knobs { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--of-s4) var(--of-s3); justify-items: center; }

@media (max-width: 1040px) {
  .of-instrument { --of-col: 164px; column-gap: var(--of-s5); }
  /* four knobs do not fit a narrow column: two and two, the hair stays inside each row */
  .of-instrument .of-path:has(> :nth-child(4)) .of-knob__label { font-size: var(--of-fs-label); }
  .of-instrument .of-path:has(> :nth-child(4)) { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--of-s4); }
  .of-instrument .of-path:has(> :nth-child(4)) > .of-knob:nth-child(odd) > .of-knob__dial::before { content: none; }
}
@media (max-width: 860px) {
  .of-instrument { grid-template: "mark mark" auto "field field" auto "time time" auto "foot foot" auto "footl footr" auto "headl headr" auto "left right" auto / minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--of-s5); padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
  .of-field { min-height: 340px; }
}

/* small helpers the layouts share */
.of-stack { display: grid; row-gap: var(--of-s3); }
.of-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--of-s2) var(--of-s4); }

/* ── A whole app on the instrument ──────────────────────────────────────
   A Data Fields app has more controls than fit one screen: the columns run on, the field stays.
   Then what is read and not played (list, statistics, about) stands under, on the plain ground. */
.of-instrument--app { min-height: 100svh; row-gap: var(--of-s6); grid-template-rows: auto auto auto auto; }
.of-instrument__centre { grid-area: field; min-width: 0; }
.of-instrument--app .of-field { position: sticky; top: var(--of-s5); height: min(72svh, 760px); margin-bottom: var(--of-s5); }
.of-instrument--app .of-instrument__headr { justify-content: flex-end; }
.of-instrument--app .of-instrument__time { display: grid; row-gap: var(--of-s4); }
.of-field__tags { position: absolute; left: var(--of-s3); top: var(--of-s3); display: grid; row-gap: var(--of-s1); font-size: var(--of-fs-label); font-weight: var(--of-w-regular); line-height: 1.2; color: var(--of-ink-2); pointer-events: none; }
.of-field__zoom { position: absolute; right: var(--of-s3); bottom: var(--of-s3); display: grid; row-gap: var(--of-s1); }
.of-field__zoom > .of-btn { width: var(--of-row); padding: 0; }
.of-tip { position: absolute; z-index: 2; pointer-events: none; padding: var(--of-s2); background: color-mix(in srgb, var(--of-ground) 90%, transparent); font-size: var(--of-fs-value); font-weight: var(--of-w-regular); line-height: 1.35; }
.of-ends { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--of-s1) var(--of-s3); padding-top: var(--of-s2); font-size: var(--of-fs-label); font-weight: var(--of-w-regular); line-height: 1.2; color: var(--of-ink-2); }
.of-hint { font-size: var(--of-fs-value); font-weight: var(--of-w-regular); line-height: 1.45; color: var(--of-ink-2); }
.of-envelope { width: 100%; height: 44px; color: var(--of-ink); }
.of-turn__b { display: grid; place-items: center; min-width: var(--of-row); min-height: var(--of-row); padding: 0; border: 0; background: none; color: var(--of-ink); cursor: pointer; }
.of-turn__b > svg { width: 34px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.of-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--of-s3); padding: var(--of-s3) var(--of-gutter); background: var(--of-ground); color: var(--of-ink); font-size: var(--of-fs-value); font-weight: var(--of-w-regular); }
.of-under { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: var(--of-s7) var(--of-s6); padding: var(--of-s7) var(--of-gutter); }
.of-under__col { display: grid; align-content: start; row-gap: var(--of-s3); min-width: 0; }

/* the list an app writes by itself, as a table: click a row to hear it */
.of-log { max-height: 360px; overflow-y: auto; font-size: var(--of-fs-value); font-weight: var(--of-w-regular); line-height: 1.35; color: var(--of-ink-2); }
.of-log table { width: 100%; border-collapse: collapse; }
.of-log td { padding: var(--of-s1) var(--of-s3) var(--of-s1) 0; vertical-align: baseline; }
.of-log td:last-child { padding-right: 0; text-align: right; }
.of-log tr { cursor: pointer; }
.of-log tr:hover td { background: color-mix(in srgb, var(--of-ink) var(--of-veil-2), transparent); color: var(--of-ink); }
.of-log tr.sel td { background: color-mix(in srgb, var(--of-ink) var(--of-veil), transparent); color: var(--of-ink); font-weight: var(--of-w-bold); }
.of-log :is(.m, .g, .t) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.of-log .m { color: var(--of-ink); font-weight: var(--of-w-bold); }
.of-log .d { display: block; }

@media (max-width: 860px) {
  .of-instrument--app .of-field { position: relative; top: 0; height: max(340px, 52svh); }
  .of-instrument--app .of-instrument__headr { justify-content: flex-start; }
}
