/* Luca OS on phones (< 760 px, PLAN 2.8 + 12.3), by C3.
   The desktop turns into an iPhone home screen: status bar, a widget row, a 4-column grid of the
   blender tiles with lowercase labels, a dock of four. Apps open as full-screen sheets with a grab
   handle (js/os/phone.js adds the handle and the swipe). Nothing here applies above 760 px. */

#statusbar, .ph-home, .sheet-grab { display: none; }

@media (max-width: 759.98px) {
  :root { --sb-h: 50px; --ph-icon: 60px; --dock-size: 60px; }

  /* ---------- status bar ---------- */
  #menubar { display: none; }
  #statusbar { display: flex; position: absolute; left: 0; right: 0; top: 0; z-index: 6; height: var(--sb-h); padding: env(safe-area-inset-top) 26px 0 34px; align-items: center; justify-content: space-between; color: #fff; pointer-events: none;
    font: 600 16px/1 var(--font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  body.tone-light #statusbar { color: #000; }
  .sb-icons { display: flex; align-items: center; gap: 6px; }
  .sb-icons svg { height: 12px; width: auto; fill: currentColor; }
  .sb-icons svg:last-child { height: 13px; }
  body.locked #statusbar { z-index: 51; }

  /* ---------- home screen ---------- */
  #icons, #stickers, #wall { display: none; }
  #desktop { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: calc(var(--sb-h) + 10px) 0 calc(var(--dock-size) + 52px); -webkit-overflow-scrolling: touch; transition: transform .35s var(--ease), filter .35s var(--ease); transform-origin: 50% 0; }
  #widgets { display: block; position: static; padding: 0 20px; }
  #widgets .w-col { display: block; }
  #widgets .w-row { gap: 16px; }
  #widgets .w-small { width: calc((100vw - 56px) / 2); height: calc((100vw - 56px) / 2); max-width: 180px; max-height: 180px; border-radius: 22px; }
  #widgets .w-photo { display: none; }

  .ph-home { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px 0; padding: 26px 14px 8px; }
  .ph-app { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; padding: 0; background: none; border: 0; color: #fff; -webkit-tap-highlight-color: transparent; }
  .ph-tile { width: var(--ph-icon); height: var(--ph-icon); display: grid; place-items: center; transition: transform .15s var(--ease), filter .15s; }
  /* the renders carry ~9% transparent margin; scale them so the squircle itself is ~60 px like iOS */
  .ph-img { width: 122%; height: 122%; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .25)); }
  .ph-img.tile-fallback { width: 100%; height: 100%; }
  .ph-app:active .ph-tile { transform: scale(.92); filter: brightness(.8); }
  .ph-label { max-width: 76px; font: 500 12px/1.15 var(--font); letter-spacing: -.01em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .7), 0 0 6px rgba(0, 0, 0, .35); }
  body.tone-light .ph-app { color: #000; }
  body.tone-light .ph-label { text-shadow: 0 0 2px rgba(255, 255, 255, .9), 0 0 8px rgba(255, 255, 255, .6); }

  /* ---------- dock of four ---------- */
  #dock-wrap { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  #dock { width: 100%; max-width: 380px; height: calc(var(--dock-size) + 30px); padding: 0 18px; border-radius: 32px; justify-content: space-between; align-items: center; }
  #dock .dock-item { width: var(--dock-size); height: var(--dock-size); align-items: center; }
  #dock .dock-icon { width: calc(var(--dock-size) * 1.22); height: calc(var(--dock-size) * 1.22); flex: none; }
  #dock .dock-item:not([aria-label="finder"]):not([aria-label="photos"]):not([aria-label="notes"]):not([aria-label="mail"]),
  #dock .dock-sep, #dock .dock-dot, .dock-tip { display: none; }

  /* ---------- apps as sheets ---------- */
  #windows { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
  #windows > * { pointer-events: auto; }
  .win.win-mobile { position: fixed; left: 0 !important; top: calc(var(--sb-h) + 8px) !important; bottom: 0; translate: none !important; width: 100% !important; height: auto !important;
    border-radius: 14px 14px 0 0; box-shadow: 0 -1px 0 rgba(255, 255, 255, .06), 0 -10px 40px rgba(0, 0, 0, .35); overflow: hidden; }
  .win-mobile .win-frame { border-radius: inherit; }
  .win-mobile .win-lights, .win-mobile .win-rz { display: none; }
  .win-mobile .win-bar { --bar-pad: 16px; padding-top: 12px; height: calc(var(--bar-h) + 12px); touch-action: none; }
  .win-mobile.chrome-unified .win-title, .win-mobile.chrome-hud .win-title { display: block !important; flex: 1; text-align: center; font: 600 15px/1 var(--font); padding: 0 16px; }
  .win-mobile.chrome-unified.has-toolbar .win-bar { justify-content: flex-start; }
  .win-mobile.chrome-unified.has-toolbar .win-title { display: none !important; }
  .win-mobile.chrome-bare .win-bar-bare { display: block; height: 22px; background: transparent; box-shadow: none; }
  .win-mobile .win-body { overscroll-behavior: contain; }
  .sheet-grab { display: block; position: absolute; left: 50%; top: 0; z-index: 3; width: 84px; height: 18px; margin-left: -42px; padding: 0; border: 0; background: none; touch-action: none; }
  .sheet-grab i { display: block; width: 36px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: rgba(127, 127, 127, .55); }
  /* the home screen recedes behind an open sheet, like ios */
  #os:has(.win-mobile:not(.minimized)) #desktop { transform: scale(.94); filter: brightness(.55); }
  #os:has(.win-mobile:not(.minimized)) #dock-wrap { opacity: 0; pointer-events: none; transition: opacity .2s; }

  /* ---------- app contents at phone width ---------- */
  .cf-doc { display: block; overflow-y: auto; overflow-x: hidden; }
  .cf-side { width: auto; border-right: 0; padding: 18px 18px 6px; }
  .cf-scroll { overflow: visible; padding: 6px 18px 28px; }
  .cf-rail { display: none; }
  .mg-strip { scroll-snap-type: x mandatory; }
  .win-mobile .fd-views { display: none; }
  .win-mobile .fd-search { width: 96px; }
  .win-mobile .fd-title { flex: 1 1 auto; min-width: 0; }
  #notifications { top: calc(var(--sb-h) + 4px); left: 8px; right: 8px; width: auto; }

  /* ---------- lock screen ---------- */
  .lk-top { top: calc(var(--sb-h) + 34px); }
  .lk-date { font-size: 19px; }
  .lk-time { font-size: 92px; }
  .lk-bottom { bottom: calc(40px + env(safe-area-inset-bottom)); }
  /* the auto-filling wall behind the lock screen is loud: dim it so the clock and name read */
  .lk-bg.lk-wall .wall-card { will-change: auto; }
  .lk-bg.lk-wall .wall-card img { opacity: .44; }
  .lk-top, .lk-name { text-shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 2px 30px rgba(0, 0, 0, .45); }
}

@media (max-width: 759.98px) and (prefers-reduced-motion: reduce) {
  #desktop { transition: none; }
}
