/* Avakode Hub — scene «offrentaudit» (assets/js/scenes/offrentaudit.js): the rental calendar by unit, the off-rent log, the
   credit request (lane 4.2). Loaded by inc/scenes.php on a family page whose stage is this scene. Classes: .or-* only; the
   common parts (.sc-head, .sc-sample, .sc-panel, .sc-stamp), the stage, the rail and the caption are scene.css. */

/* The height of the stage before the module arrives = the height it takes (measured at 1440 / 768 / 390, e2e: ≤ 4px apart).
   --stage-h: two columns (the calendar left, the log and the letter right); --stage-h-narrow: a window ≤ 720px (rail on top).
   From 721px the rail is on the left; the stage goes one column when the figure is ≤ 980px (window ≤ 1014px: the page padding
   takes 32px), hence the middle value. If the family page changes its padding, re-measure. */
.hub-scene[data-scene="offrentaudit"] { --stage-h: 546px; --stage-h-narrow: 1019px; }
@media (min-width: 721px) and (max-width: 1014px) {
  .hub-scene[data-scene="offrentaudit"] { --stage-h: 902px; }
}

/* columns: the calendar 1.5fr, the log and the letter 1fr; the three are in one grid, so the stage is as high as it needs */
.or-scene { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 0 28px; align-items: start; }
.or-cal { grid-column: 1; grid-row: 1 / span 2; position: relative; }
.or-log { grid-column: 2; grid-row: 1; padding: 12px 14px; }
.or-letter { grid-column: 2; grid-row: 2; position: relative; margin-top: 22px; padding: 28px 16px 16px; } /* the head sits under the stamp, which straddles the top edge */

/* the calendar: a week axis, a row per unit — the label line (unit, tag) over the track (bars of the invoice lines) */
.or-axis { position: relative; height: 18px; margin-bottom: 4px; font-size: 10px; letter-spacing: .06em; color: var(--muted); }
.or-axis span { position: absolute; left: calc(var(--at) / var(--span) * 100%); top: 0; white-space: nowrap; }
.or-row { padding: 12px 0 14px; border-top: 1px solid var(--line); }
.or-row:last-child { border-bottom: 1px solid var(--line); }
.or-label { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 14px; margin-bottom: 12px; }
.or-unit { color: var(--fg); }
.or-tag { margin-left: auto; font-size: 11px; letter-spacing: .04em; color: var(--signal-hot); }
.or-tag.is-quiet { color: var(--muted); }
.or-track {
  position: relative; height: 20px;
  /* a day is a faint tick, a week a hairline */
  background:
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / calc(700% / var(--span)) 100% repeat-x,
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px) 0 0 / calc(100% / var(--span)) 100% repeat-x;
}
.or-bill,
.or-after {
  position: absolute; top: 0; bottom: 0; transform-origin: 0 50%;
  left: calc(var(--from) / var(--span) * 100% + 1px); width: calc(var(--len) / var(--span) * 100% - 2px);
  border-radius: 3px;
}
.or-bill { border: 1px solid rgba(255, 255, 255, .22); background: rgba(169, 163, 196, .16); }
/* the days after the off-rent day: signal colour AND a hatch, so the difference does not rest on colour alone */
.or-after {
  border: 1px solid var(--signal);
  background: repeating-linear-gradient(135deg, rgba(124, 92, 252, .62) 0 4px, rgba(124, 92, 252, .26) 4px 8px);
}
/* the mark of an off-rent record: a line over the track on the day of the record, a dot on top */
.or-mark { position: absolute; top: -5px; bottom: -5px; left: calc(var(--at) / var(--span) * 100%); width: 2px; margin-left: -1px; background: var(--fg); }
.or-mark::before { content: ''; position: absolute; top: -4px; left: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--fg); }

/* the dot of a record is the dot of its mark on the calendar */
.or-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px; font-size: 10.5px; letter-spacing: .04em; color: var(--muted); }
.or-legend span { display: inline-flex; align-items: center; gap: 7px; }
.or-key { display: inline-block; width: 16px; height: 10px; border-radius: 2px; }
.or-key.is-bill { border: 1px solid rgba(255, 255, 255, .22); background: rgba(169, 163, 196, .16); }
.or-key.is-after { border: 1px solid var(--signal); background: repeating-linear-gradient(135deg, rgba(124, 92, 252, .62) 0 3px, rgba(124, 92, 252, .26) 3px 6px); }
.or-key.is-mark { width: 2px; height: 12px; border-radius: 0; background: var(--fg); }

.or-log-row {
  display: grid; grid-template-columns: 78px 62px minmax(0, 1fr); gap: 8px; padding: 6px 0; white-space: nowrap;
  border-top: 1px solid var(--line); color: var(--fg-2);
}
.or-log-row span:first-child::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--fg); }
.or-log-row b { font-weight: 500; text-align: right; color: var(--fg); font-variant-numeric: tabular-nums; }

.or-letter-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.or-letter-line b { grid-column: 2; grid-row: 1; font-weight: 500; font-variant-numeric: tabular-nums; }
.or-letter-line em, .or-letter-line small { grid-column: 1 / -1; font-style: normal; font-size: 11px; }
.or-letter-line em { color: var(--signal-hot); }
.or-letter-line small { color: var(--fg-2); }
.or-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--signal); }
.or-total span { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-2); }
.or-total b { font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--signal-hot); }
.or-fly {
  position: absolute; left: 0; top: 0; display: flex; gap: 14px; padding: 5px 10px; white-space: nowrap; pointer-events: none;
  border: 1px solid var(--signal); border-radius: 4px; background: #1A1430; color: var(--fg); opacity: 0;
}
.or-fly b { font-weight: 500; color: var(--signal-hot); }

/* one column when the figure is ≤ 980px (the right column would get narrower than ~320px): the calendar, then the log, then the letter */
@container (max-width: 980px) {
  .or-scene { grid-template-columns: minmax(0, 1fr); }
  .or-cal, .or-log, .or-letter { grid-column: 1; grid-row: auto; }
  .or-log { margin-top: 20px; }
  .or-letter { margin-top: 26px; }
  .or-row { padding: 9px 0 11px; }
  .or-label { margin-bottom: 11px; }
}

/* a narrow stage: the type of the log and the letter keeps 11px and more */
@container (max-width: 760px) {
  .or-tag { font-size: 12px; }
  .or-log-row { grid-template-columns: 70px 62px minmax(0, 1fr); gap: 6px; }
  .or-letter-line em, .or-letter-line small { font-size: 11.5px; }
  .or-total b { font-size: 18px; }
}

/* rail on top (window ≤ 720px): the stage is at most ~650px and from 324px; the tag of a row takes its own line there, always,
   so the height of the stage does not depend on whether the name and the tag happen to fit side by side */
@media (max-width: 720px) {
  .or-tag { flex-basis: 100%; text-align: right; }
}
