/* ==========================================================================
   devanshi jain — objects (the bars and the scrolling frame are in page.css)
   A chart: chapters across, object numbers down, each object's cut-out in its cell.
   The chosen object shows large in a panel fixed on the right (a sheet on phones).
   ========================================================================== */

.objects-page {
  --panel-w: clamp(300px, 26vw, 400px);
  --hair: #dcdcda;                       /* hairlines */
  --mark: #a9abaa;                       /* axis labels */
  --mark-off: #cfd0ce;                   /* the light + of an empty cell */
  --pic: clamp(44px, 4.4vw, 70px);       /* an object's size in the chart */
}
p { margin: 0; }

/* ---------- the chart ---------- */
.ob-frame { right: calc(var(--panel-w) + clamp(16px, 2vw, 32px)); }
.ob-chart {
  display: grid; grid-template-columns: 4.6em repeat(9, minmax(0, 1fr));
  /* the rows + the heading row (--rows, set by objects.js) share the height between the bars,
     never under 22px (it scrolls if there are more) */
  grid-auto-rows: clamp(22px, calc((100vh - var(--frame-top) - var(--frame-bottom) - 2 * var(--fade)) / var(--rows, 19)), 44px);
  padding: var(--fade) 0 var(--fade) var(--side);
}
.ob-axis, .ob-head { align-self: end; padding-bottom: .9em; font-size: .82em; letter-spacing: .04em; white-space: nowrap; }
.ob-axis { color: var(--mark); }
.ob-head { text-align: center; color: var(--ink); }
.ob-axis--x { text-align: center; }
.ob-num { align-self: center; font-size: .82em; letter-spacing: .04em; font-variant-numeric: tabular-nums; color: var(--ink-soft); }
.ob-cell { position: relative; display: grid; place-items: center; }

/* the marks: a light + for an empty cell, a dark + for an object (hover or click shows it) */
.ob-plus { display: block; width: 9px; height: 9px; fill: none; stroke: currentColor; stroke-width: 1; stroke-linecap: round; }
.ob-empty { color: var(--mark-off); }
.ob-pick {
  position: absolute; z-index: 1; inset: 0;                 /* the whole cell is the tap area */
  display: grid; place-items: center;
  padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
/* an object shown as its picture: centred on its cell, larger than the cell (as in the owner's layout) */
.ob-pick--pic { inset: auto; left: 50%; top: 50%; width: var(--pic); height: var(--pic); margin: calc(var(--pic) / -2) 0 0 calc(var(--pic) / -2); z-index: 2; }
/* pictures in the chart: same-sized square crops, like an archive contact sheet */
.ob-pick--pic { display: block; background: var(--paper); box-shadow: 0 0 0 6px var(--paper); }   /* a paper margin, so neighbouring + marks don't peek out at the edges */
.ob-pick img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .45s cubic-bezier(.22, .61, .25, 1), opacity .3s ease; }
.ob-pick .ob-plus { transition: transform .3s ease, opacity .3s ease; }
@media (hover: hover) {
  .ob-pick:hover img { transform: scale(1.08); }
  .ob-pick:hover .ob-plus { transform: scale(1.35); }
}
@media (hover: none) { .ob-pick:active { opacity: .6; } }
/* the chosen object lights up and the other pictures fade (objects.js adds .has-pick to the chart and .is-on to it).
   A + that is chosen shows its picture in its cell, the same square as the pictures in the chart. */
.ob-pick__pic {
  position: absolute; left: 50%; top: 50%; z-index: 3; width: var(--pic); height: var(--pic);
  margin: calc(var(--pic) / -2) 0 0 calc(var(--pic) / -2);
  background: var(--paper); box-shadow: 0 0 0 6px var(--paper); opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .35s ease, visibility 0s linear .35s;
}
.ob-pick.is-on .ob-pick__pic { opacity: 1; visibility: visible; transition: opacity .35s ease, visibility 0s; }
.ob-pick.is-on:has(.ob-pick__pic) .ob-plus { opacity: 0; }   /* an object without a photo keeps its mark when chosen */
.ob-pick.is-on { z-index: 4; }
.has-pick .ob-pick--pic:not(.is-on) img { opacity: .18; }
/* the dark + marks never fade: they must always read as objects, distinct from the light (empty) ones */

/* ---------- the panel (fixed, right) ---------- */
.ob-panel {
  position: fixed; z-index: 2; right: 0; top: calc(var(--frame-top) - 8px); bottom: var(--frame-bottom);
  width: var(--panel-w);
  display: flex; flex-direction: column;
  padding: 0 var(--right) 0 clamp(20px, 2.2vw, 36px);
  border-left: 1px solid var(--hair);
}
.ob-handle { display: none; }
.ob-item { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding-top: 2px; }
.ob-item[hidden] { display: none; }
.ob-item__top { display: flex; justify-content: space-between; font-size: .82em; letter-spacing: .04em; color: var(--ink-soft); }
.ob-item__pic { position: relative; flex: 1 1 auto; min-height: 120px; margin: clamp(14px, 3vh, 32px) 0; }
/* the picture fits the space left above the text, whatever its shape */
.ob-item__pic img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; }
.ob-item__text { color: var(--ink); line-height: 1.55; padding-bottom: clamp(12px, 2.4vh, 24px); }
.ob-item__text p + p { margin-top: .9em; }
/* the object's record: each field's name in a lighter ink beside its value, one text size; a long record
   scrolls inside the panel so the picture keeps its room */
.ob-item__text { flex: 0 1 auto; min-height: 0; max-height: 44%; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain; }
/* a record that runs on fades out at the foot of the panel, so it reads as scrollable */
.ob-item__text.is-long { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent); }
.ob-item__text.is-long.is-end { -webkit-mask-image: none; mask-image: none; }
.ob-item__text::-webkit-scrollbar { display: none; }
.ob-record { margin: 0; }
.ob-record__row { display: grid; grid-template-columns: 6.6em minmax(0, 1fr); column-gap: .8em; }
.ob-record__row + .ob-record__row { margin-top: .45em; }
.ob-record dt { color: #a3a5a4; }
.ob-record dd { margin: 0; color: var(--ink); }
/* an acquisition link (enquire, the oblist): the record's own text, with a hairline underline and a
   finger-sized tap area */
.ob-record__link { position: relative; color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: #c4c5c4; touch-action: manipulation; }
.ob-record__link::after { content: ""; position: absolute; inset: -10px -12px; }
@media (hover: hover) { .ob-record__link:hover { opacity: .6; } }
@media (hover: none) { .ob-record__link:active { opacity: .55; } }
.ob-record__link:focus-visible { outline: 1px dotted var(--ink); outline-offset: 3px; }
.ob-record + .ob-item__more { margin-top: .9em; }
/* an object whose photo is still to come: its record moves up into the picture's room */
.ob-item__pic--none { flex: 0 0 0; min-height: 0; margin: 0 0 clamp(14px, 3vh, 32px); }
.ob-item__pic--none + .ob-item__text { max-height: none; }
/* a note that belongs to the record (the bodices' accompanying-garments note): quieter, after it */
.ob-note { margin-top: 1em !important; color: #a3a5a4; }
.ob-note + .ob-note { margin-top: .6em !important; }
.ob-item__link { margin-top: 1em !important; }
.ob-item__more a { position: relative; display: inline-block; }
.ob-item__more a::after { content: ""; position: absolute; inset: -10px -12px; }
@media (hover: hover) { .ob-item__more a:hover { opacity: .6; } }

.ob-nav {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--hair); padding: clamp(12px, 2vh, 20px) 0 0;
  font-size: .82em; letter-spacing: .06em; font-variant-numeric: tabular-nums; color: var(--ink-soft);
}
.ob-nav__btn {
  position: relative; display: grid; place-items: center; width: 30px; height: 22px; padding: 0;
  border: 0; background: none; color: var(--ink); cursor: pointer;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.ob-nav__btn::after { content: ""; position: absolute; inset: -11px -8px; }
.ob-nav__btn svg { display: block; width: 22px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .ob-nav__btn:hover { opacity: .6; } }
@media (hover: none) { .ob-nav__btn:active, .ob-item__more a:active { opacity: .55; } }

/* desktop and tablet: the record in a smaller size (the owner's request), so most of it reads beneath the
   picture without scrolling; the text keeps its share of the panel, so the picture's size is unchanged */
@media (min-width: 720px) {
  .ob-item__text { font-size: calc(var(--text) * .8); line-height: 1.5; }
  .ob-item__pic:not(.ob-item__pic--none) + .ob-item__text { flex: 0 0 44%; }
  .ob-record__row + .ob-record__row { margin-top: .3em; }
  .ob-note { margin-top: .85em !important; }
  .ob-note + .ob-note { margin-top: .45em !important; }
}

/* the sound control sits under the panel, so the panel ends above it (it already does: bottom = frame-bottom) */

/* ---------- tablets: narrower panel ---------- */
@media (max-width: 1100px) { .objects-page { --panel-w: 280px; --pic: 44px; } }

/* ---------- phones: the chart fills the screen; choosing an object opens a sheet from the bottom ---------- */
@media (max-width: 719px) {
  .objects-page { --pic: 34px; }
  .ob-frame { right: 0; }
  /* as fine as on desktop: a phone's screen draws a 1px line three pixels thick, so the marks and
     arrows use thinner strokes here; the last, unlabelled column of empty marks goes */
  .ob-chart { grid-template-columns: 2.9em repeat(8, minmax(0, 1fr)); grid-auto-rows: 28px; padding: 4px var(--right) 16px var(--side); }
  .ob-axis--x, .ob-cell[data-ch="-"] { display: none; }
  .ob-plus { width: 8px; height: 8px; stroke-width: .45; }
  .ob-empty { color: #d6d7d5; }
  .ob-axis, .ob-head { font-size: .76em; padding-bottom: .8em; }
  .ob-head { color: var(--ink-soft); }
  .ob-axis--y { font-size: 0; }                      /* no room for the axis words; the numerals say it */
  .ob-num { font-size: .72em; color: var(--mark); }

  /* the panel is a sheet fixed along the bottom, always there (as in the owner's layout); the chart
     scrolls above it. Its handle folds it down to one line and back. */
  .objects-page { --sheet-h: min(41vh, 350px); --sheet-min: 58px; }
  .ob-frame { bottom: var(--sheet-h); transition: bottom .35s ease; }
  .objects-page:has(.ob-panel.is-collapsed) .ob-frame { bottom: var(--sheet-min); }
  .objects-page .foot, .objects-page .sound { display: none; }   /* the sheet takes the bottom of the screen */
  .ob-panel {
    z-index: 5; top: auto; bottom: 0; left: 0; right: 0; width: auto; height: var(--sheet-h);
    padding: 0 var(--right) calc(14px + env(safe-area-inset-bottom, 0px)) var(--side);
    border-left: 0; background: var(--paper);
    box-shadow: 0 -1px 0 var(--hair);                /* a single hairline, like the desktop panel's edge */
    overflow: hidden; transition: height .35s ease;
  }
  .ob-panel.is-collapsed { height: calc(var(--sheet-min) + env(safe-area-inset-bottom, 0px)); }
  .ob-panel.is-collapsed .ob-item__pic, .ob-panel.is-collapsed .ob-item__text, .ob-panel.is-collapsed .ob-nav { visibility: hidden; }
  /* no handle: the sheet stays open (the owner found a fold line that did little misleading) */
  .ob-panel { padding-top: 16px; }
  /* the picture on the left, the description beside it on the right (room for several lines) */
  .ob-item {
    display: grid; grid-template-columns: 46% minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    column-gap: 18px;
  }
  .ob-item__top { grid-column: 1 / -1; }
  .ob-item__pic { min-height: 0; margin: 12px 0 10px; }
  .ob-item__pic img { object-position: left top; }
  .ob-item__text { margin: 12px 0 10px; padding: 0; line-height: 1.5; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .ob-item__text p + p { margin-top: .35em; }
  .ob-item__text { max-height: none; }
  .ob-item__pic--none { display: none; }
  .ob-item__pic--none + .ob-item__text { grid-column: 1 / -1; }
  .ob-record__row { grid-template-columns: 1fr; }
  .ob-record__row + .ob-record__row { margin-top: .35em; }
  .ob-nav { padding-top: 8px; }
  .ob-nav__btn { height: 18px; }
  .ob-nav__btn svg { stroke-width: .55; }
  .ob-item__top, .ob-nav { font-size: .76em; }
}
@media (prefers-reduced-motion: reduce) { .ob-pick img, .ob-panel, .ob-frame { transition: none !important; } }

/* arriving from a chapter page: the other chapters fade back (objects.js adds .is-dim) */
.ob-head, .ob-plus, .ob-empty { transition: opacity .5s ease; }
/* faded enough to step back, not so far that a dark + (an object) looks like a light one (empty).
   Only what's inside a cell fades; a picture keeps its solid paper square, so no + shows through it. */
.ob-head.is-dim, .ob-cell.is-dim .ob-plus, .ob-cell.is-dim .ob-empty { opacity: .4; }
.ob-cell.is-dim .ob-pick--pic img { opacity: .18; }
