/* ARENA — Apple-style layer (TEST COPY ONLY).
   Built from Emil Kowalski's "apple-design" skill (Apple's WWDC talks, for the web).
   To remove it: delete the apple.css and apple.js lines in index.html. */

/* ---------- 1. Response: no tap delay, feedback the moment a finger lands ---------- */
html { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

:is(.btn, .tile, .rows button, .nav a, .bottom-nav a, .bottom-nav button, .top .tool, .day, .choices button, .tabs button, .help, .sizer button):not(.m-hold) {
  transition: transform .1s ease-out, background-color .15s ease-out, border-color .15s ease-out, box-shadow .12s ease-out, color .15s ease-out;
}
:is(.btn, .tile, .rows button, .nav a, .bottom-nav a, .bottom-nav button, .top .tool, .day, .choices button, .tabs button, .help, .sizer button):not(.m-hold):not(:disabled):active {
  transform: scale(.97);
  transition-duration: .06s;          /* in fast, out a little slower */
}
html.motion .btn.primary:not(.m-hold):active { transform: scale(.97); }
html.motion .tile:hover { transform: none; box-shadow: none; }   /* no lift on hover: a work tool stays still */
tr.clickable:active > * { background: var(--frame); }

/* ---------- 2. Restraint: a page used 100 times a day opens almost instantly ---------- */
html.motion .m-enter > .page > * { animation-duration: .2s; animation-delay: 0s !important; }
html.motion .m-enter .todo li, html.motion .m-enter tbody tr { animation: none; }
html.motion .m-enter .title-block .pole { animation-duration: .45s; }
html.motion .m-enter .bar-fill, html.motion .m-enter .col-a, html.motion .m-enter .col-b { animation-duration: .45s; animation-delay: 0s; }

/* ---------- 3. Sheets, menu and toast move with springs in apple.js, so the CSS keyframes step aside ---------- */
html.motion .overlay.m-in, html.motion .overlay.m-in .dialog, html.motion .toast.m-in { animation: none; }
.overlay { --p: 1; background: rgb(6 16 106 / calc(.38 * var(--p))); }
.apple-ghost { pointer-events: none !important; }
.apple-ghost * { pointer-events: none !important; }

@media (max-width: 640px) {
  /* a grab bar says "this can be pulled down" */
  .overlay .dialog { position: relative; padding-top: 30px; touch-action: pan-y; will-change: transform; }
  .overlay .dialog::before { content: ""; position: absolute; top: 10px; inset-inline: 0; margin: 0 auto; width: 40px; height: 5px; border-radius: 99px; background: var(--control); }
  /* the page behind steps back while a sheet is up (dim to focus) */
  body.apple-sheet { background: #000048; }
  body.apple-sheet .app { transform-origin: 50% 0; }
}
@media (max-width: 900px) {
  .side.open { will-change: transform; }
  .side.open::before { content: ""; display: block; flex: none; align-self: center; width: 40px; height: 5px; margin: -6px auto 6px; border-radius: 99px; background: var(--control); }
}
.toast { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; will-change: transform; }

/* ---------- 4. Materials: the phone's top and bottom bars are glass, content scrolls under them ---------- */
@media (max-width: 900px) {
  .top {
    background: color-mix(in srgb, var(--frame) 72%, transparent);
    -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
    box-shadow: none; transition: box-shadow .2s ease-out;
  }
  html.apple-scrolled .top { box-shadow: 0 1px 0 rgb(6 16 106 / .08), 0 6px 16px -8px rgb(6 16 106 / .18); }   /* edge only once content is under it */
  .bottom-nav {
    background: color-mix(in srgb, var(--white) 70%, transparent);
    -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
    border-top-color: rgb(255 255 255 / .5);
    box-shadow: 0 -1px 0 rgb(6 16 106 / .08), 0 -8px 24px rgb(6 16 106 / .06);
  }
  .bottom-nav [aria-current="page"] { font-weight: 700; }
}
@media (prefers-reduced-transparency: reduce) {
  .top, .bottom-nav { background: var(--white) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .top { background: var(--frame) !important; }
}
@media (prefers-contrast: more) {
  .top, .bottom-nav { background: var(--white) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; border-color: var(--heading) !important; }
}

/* ---------- 5. Typography: tracking changes with size (Latin only — Arabic letters must stay joined) ---------- */
h1, h2, h3, .facts .v, .tile b { font-optical-sizing: auto; }
:lang(en) .title-row h1, :lang(en) .login form h1 { letter-spacing: -.015em; line-height: 1.15; }
:lang(en) .dialog h2 { letter-spacing: -.01em; line-height: 1.2; }
:lang(en) .tile b, :lang(en) .facts .v { letter-spacing: -.01em; }
:lang(en) :is(.bottom-nav span, .tile span) { letter-spacing: .01em; }
:lang(ar) .title-row h1 { line-height: 1.35; }   /* Arabic needs room above and below */

/* ---------- 6. Reduced motion: gentle fades, never slides or springs ---------- */
@media (prefers-reduced-motion: reduce) {
  :is(.btn, .tile, .rows button, .nav a, .bottom-nav a, .bottom-nav button, .top .tool, .day, .choices button, .tabs button):active { transform: none !important; }
}
