/* apple-polish.css - interface craft, from Apple's design guidance.
 *
 * Loaded LAST, after workspace.css and theme-professional.css, so a selector
 * here that ties with one of theirs wins. That is deliberate and it cuts both
 * ways, so every rule below is written to be no MORE specific than it has to
 * be - the `.nav-item` lesson recorded in CLAUDE.md, where a reset written at
 * (0,2,0) silently outranked the `:hover` and `.active` states it tied with.
 *
 * DELIBERATE SCOPE. This is additive craft, not a sweep: it adds press
 * feedback, size-specific tracking, material depth on the four modals, and the
 * two accessibility preferences the app did not answer. It does NOT retune the
 * ~200 hardcoded colour values - with no frontend test runner that is the
 * unverifiable diff the P7 notes warn against.
 *
 * What is NOT here, and why: this app has no gesture-driven surface - nothing
 * is dragged, flicked or swiped - so the spring, velocity-handoff, momentum
 * projection and rubber-banding parts of that guidance have nothing to attach
 * to. Adding a spring library to animate a modal that only ever opens and
 * closes would be motion for its own sake. If a draggable panel or a swipeable
 * sheet ever lands, that is when those rules start earning their place.
 */

/* ══ 1. Response - feedback belongs on the press, and it is instant ═══════ */
/*
 * "The moment lag appears, the feeling of directness falls off a cliff."
 * Every control here previously responded only on :hover (which a touch device
 * does not have) and on the round trip (which is a network away). A press is
 * acknowledged in 100ms, locally, before anything is sent.
 *
 * transform only - it is compositor-friendly, so this costs no layout.
 */
.btn:active,
.btn-sm:active,
.btn-rd:active,
.bell-btn:active,
.layout-btn:active,
.qv:active,
.modal-footer button:active,
.cl-add-btn:active,
.rd-mate-x:active {
  transform: scale(.97);
  /* Named explicitly because several of these inherit `transition: all .2s`,
     which would stretch a press acknowledgement over 200ms and lose the point. */
  transition: transform 100ms ease-out;
}

/* The sidebar items scale less: they are wide, and a 3% squeeze on a full-width
   row reads as the layout shifting rather than as a button being pressed. */
.nav-item:active {
  transform: scale(.99);
  transition: transform 100ms ease-out;
}

/* A checkbox is a state, not a button, so it gets a press cue rather than a
   squeeze - the tick itself is the feedback and it is already instant. */
.cl-box:active,
.document-checkbox:active { transform: scale(.92); transition: transform 100ms ease-out; }


/* ══ 2. Typography - tracking is size-specific, never one value ═══════════ */
/*
 * Letters read too far apart as they grow, and too tight as they shrink. Large
 * display text wants NEGATIVE tracking; body copy sits near zero and is left
 * alone here. Leading tightens as size grows for the same reason.
 *
 * Element selectors (0,0,1) on purpose: they are the weakest thing that can
 * carry this, so every existing class rule still wins on the properties it
 * actually sets, and these only fill in the ones nothing sets.
 */
h1 { letter-spacing: -.021em; line-height: 1.1; }
h2 { letter-spacing: -.017em; line-height: 1.2; }
h3 { letter-spacing: -.012em; }

/* Numerals in a table should line up in a column. Tabular figures are what the
   font already ships for this; without them a score of 111 is visibly narrower
   than 100 and the column edge wobbles row to row. */
.col-score,
.notif-item .days,
.pc-stat-value,
td .due-ok, td .due-soon, td .due-overdue {
  font-variant-numeric: tabular-nums;
}

/* Small text takes slightly POSITIVE tracking - the mirror of the rule above,
   and the reason a single letter-spacing value is always wrong somewhere. */
.rd-gate-hint,
.notif-item .meta { letter-spacing: .006em; }


/* ══ 3. Material and depth on the four modals ════════════════════════════ */
/*
 * "Dim to focus." A modal task pairs its surface with a dimming scrim and
 * pushes the background back. The scrim was already there; the blur is what
 * makes it read as depth rather than as a grey sheet, and it is what separates
 * a dialog from the busy table underneath it.
 *
 * All four modals share .modal-overlay, so this is one rule rather than four.
 */
.modal-overlay {
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px) saturate(115%);
  -webkit-backdrop-filter: blur(6px) saturate(115%);
}

/*
 * "Materialize, don't just fade." The dialog used to slide down 30px, which is
 * a card arriving from off-screen - but these dialogs come from the middle of
 * the screen, not from an edge, so the motion pointed nowhere. Scaling up from
 * just under full size with the opacity reads as the surface forming in place,
 * which is where it actually is.
 *
 * The curve overshoots slightly (the 1.6 on the third control point). That is
 * the one place a little bounce is right per the guidance: it is the arrival of
 * a physical thing. Everything else in this file is critically damped.
 */
.modal-dialog,
.picker-dialog,
.reg-dialog {
  animation: aventaMaterialize .28s cubic-bezier(.22, 1, .36, 1);
  transform-origin: center center;
}

@keyframes aventaMaterialize {
  from { transform: scale(.965); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* Bigger surfaces read as thicker: a deeper shadow than a chip gets, so the
   dialog sits above the page rather than on it. */
.picker-dialog,
.reg-dialog { box-shadow: 0 24px 70px rgba(0, 0, 0, .34); }

/* The bell dropdown is a POPOVER, not a modal: it belongs to the button that
   opened it, so it scales from its own top-right corner rather than its centre.
   Anchoring a popover to its trigger is what makes the relationship obvious. */
.notif-dropdown.open,
.layout-menu.open {
  animation: aventaPopover .18s cubic-bezier(.22, 1, .36, 1);
  transform-origin: top right;
}

@keyframes aventaPopover {
  from { transform: scale(.96) translateY(-4px); opacity: 0; }
  to   { transform: scale(1) translateY(0);      opacity: 1; }
}


/* ══ 4. Scroll edge, not a hard divider ══════════════════════════════════ */
/*
 * A wide table scrolls sideways inside .table-scroll, and nothing said so - the
 * content simply stopped at the edge, which reads as "that is all there is".
 * A short fade at the right edge says there is more, without adding a rule, a
 * shadow or a scrollbar that only appears on hover.
 *
 * Applied only while the box actually overflows, which `mask-image` cannot ask
 * on its own - so it is painted unconditionally and is invisible when the
 * content fits, because there is nothing under the fade to see.
 */
.table-scroll {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
          mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
}

/* ...except the actions column is sticky at the right edge and must stay fully
   legible: fading the one column whose buttons the user is reaching for is
   worse than no hint at all. A sticky cell paints above the mask only if the
   mask is not on its ancestor, so the fade is dropped on any table that has
   one. */
.table-scroll:has(.col-actions) {
  -webkit-mask-image: none;
          mask-image: none;
}


/* ══ 5. The two preferences the app did not answer ═══════════════════════ */
/*
 * prefers-reduced-motion is already handled in workspace.css (it zeroes every
 * animation and transition globally), so it is deliberately not repeated here -
 * that rule already covers everything above.
 */

/* "Make translucent surfaces frostier or solid: raise the opacity, drop the
   blur." Someone who has asked for less transparency has usually asked because
   the blur costs them legibility, so the answer is a solid scrim. */
@media (prefers-reduced-transparency: reduce) {
  .modal-overlay {
    background: rgba(0, 0, 0, .72);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* "Near-solid backgrounds with a defined, contrasting border." The press
   feedback stays - it is shape, not colour, and it is the one cue that does not
   depend on contrast at all. */
@media (prefers-contrast: more) {
  .modal-dialog,
  .picker-dialog,
  .reg-dialog,
  .notif-dropdown,
  .layout-menu {
    border: 2px solid currentColor;
  }
  .modal-overlay {
    background: rgba(0, 0, 0, .8);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  /* A focus ring has to survive a high-contrast theme too, and `outline` with
     no colour inherits the element's own - which is how the Professional
     palette lost its ring on primary buttons once. Stated, never inherited. */
  :focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
}
