/* "AudiOS" home screen for personal.html's landing view -- active only while
   body.theme-os is set by assets/personal-os.js.
   v2: MacBook (desktop) / iPad (tablet) / phone frame; the original
   masterpiece marquee sits at the top of the screen; app icons are the
   categories' own cover photos. */

body.theme-os .hero-title,
body.theme-os .hero-sub,
body.theme-os .gallery-wrap > .pcms-admin-only[onclick="openDraftModal()"],
body.theme-os #landingView > .gallery-section { display: none !important; }
body.theme-os .gallery-wrap { max-width: 1180px; }

#osView { display: none; font-family: -apple-system, 'SF Pro Display', 'Segoe UI', 'Outfit', 'Mitr', var(--font-body, 'Plus Jakarta Sans', 'Sarabun'), sans-serif; color: #fff; margin: 6px 0 14px; }
body.theme-os #osView { display: block; }
#osView button { font: inherit; color: inherit; }
#osView .os-app:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 18px; }

/* ---------- MacBook: lid + screen + aluminium base ---------- */
.os-machine { position: relative; }
.os-device { position: relative; border-radius: 22px 22px 8px 8px; padding: 16px 16px 20px; background: #0c0c0f;
    box-shadow: 0 0 0 2px #3a3a42, inset 0 0 0 1px rgba(255,255,255,0.07), 0 30px 70px rgba(0,0,0,0.55); }
.os-cam { position: absolute; left: 50%; top: 6px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: #1f2937; box-shadow: inset 0 0 2px #4b5563; }
.os-screen { position: relative; overflow: hidden; border-radius: 10px; padding: 8px 26px 18px;
    background:
        radial-gradient(ellipse 60% 50% at 12% 8%, rgba(255,120,190,0.5), transparent 60%),
        radial-gradient(ellipse 55% 55% at 92% 18%, rgba(90,140,255,0.5), transparent 60%),
        radial-gradient(ellipse 70% 60% at 50% 105%, rgba(140,80,255,0.55), transparent 65%),
        linear-gradient(160deg, #241448 0%, #120b2a 55%, #1a0f3a 100%); }
.os-base { position: relative; height: 18px; margin: 0 -5%; border-radius: 2px 2px 14px 14px;
    background: linear-gradient(180deg, #d9dce2 0%, #b5b9c2 45%, #8d919b 100%); box-shadow: 0 14px 26px rgba(0,0,0,0.5); }
.os-base span { position: absolute; left: 50%; top: 0; width: 16%; height: 7px; transform: translateX(-50%); border-radius: 0 0 10px 10px; background: linear-gradient(180deg, #9ea2ab, #c3c7cf); }

.os-status { display: flex; justify-content: space-between; align-items: center; height: 26px; font-size: .82rem; font-weight: 500; opacity: .92; }
.os-status b { font-weight: 700; }
.os-sys { font-size: .75rem; }

/* The site's own masterpiece strip, living on the screen. */
.os-mp-slot { margin: 6px -26px 18px; }
.os-mp-slot #masterpieceSection { margin: 0; padding: 12px 0 14px; background: rgba(0,0,0,0.22); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid rgba(255,255,255,0.08); border-bottom: 1px solid rgba(255,255,255,0.08); }
.os-mp-slot #masterpieceSection .gallery-header { padding: 0 26px; margin-bottom: 10px; }
.os-mp-slot #masterpieceSection .gallery-header h2 { font-size: 1.1rem; margin: 0; }

/* ---------- app grid (cover-photo icons) ---------- */
.os-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 22px 10px; justify-items: center; padding: 4px 0 22px; }
.os-app { display: flex; flex-direction: column; align-items: center; gap: 7px; width: 100%; max-width: 100px; min-width: 0; border: 0; background: none; padding: 0; cursor: pointer; }
.os-icon { position: relative; display: block; width: 76px; height: 76px; border-radius: 19px; background: #222;
    box-shadow: 0 8px 18px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.12); transition: transform .2s cubic-bezier(.2,.8,.2,1); }
.os-icon img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.os-icon::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0) 42%); }
.os-app:hover .os-icon { transform: translateY(-3px) scale(1.06); }
.os-app:active .os-icon { transform: scale(.92); }
.os-label { font-size: .8rem; font-weight: 500; text-shadow: 0 1px 3px rgba(0,0,0,0.6); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.os-badge { position: absolute; right: -7px; top: -7px; z-index: 1; min-width: 22px; height: 22px; padding: 0 6px; box-sizing: border-box; display: grid; place-items: center;
    border-radius: 11px; background: #ff3b30; color: #fff; font-style: normal; font-size: .72rem; font-weight: 700; box-shadow: 0 0 0 2px rgba(20,12,40,0.85); }
.ic-new { display: grid; place-items: center; background: rgba(255,255,255,0.15); border: 2px dashed rgba(255,255,255,0.55); box-sizing: border-box; }
.ic-new b { font-size: 1.9rem; font-weight: 300; }

/* ---------- dock ---------- */
.os-dock { display: flex; justify-content: center; gap: 22px; width: max-content; max-width: 100%; margin: 0 auto; padding: 12px 20px; border-radius: 26px; box-sizing: border-box;
    background: rgba(255,255,255,0.16); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px); box-shadow: inset 0 1px 0 rgba(255,255,255,0.2); }
.os-dock .os-app { width: auto; }
.os-dock .os-icon { width: 62px; height: 62px; border-radius: 16px; }
.os-home-bar { display: none; }

/* ---------- open-app zoom ---------- */
.os-zoom { position: fixed; z-index: 4000; border-radius: 19px; pointer-events: none; background: #111 center / cover no-repeat; transition: all .33s cubic-bezier(.2,.8,.2,1); }
.os-zoom.is-open { left: 0 !important; top: 0 !important; width: 100vw !important; height: 100vh !important; border-radius: 0; }
.os-zoom.is-fade { opacity: 0; transition: opacity .35s ease; }

@media (prefers-reduced-motion: reduce) { .os-icon { transition: none; } }

/* iPad: no base, even bezel, home bar */
@media (max-width: 900px) {
    .os-base { display: none; }
    .os-device { border-radius: 30px; padding: 16px; }
    .os-screen { border-radius: 16px; padding: 8px 18px 14px; }
    .os-mp-slot { margin: 6px -18px 16px; }
    .os-mp-slot #masterpieceSection .gallery-header { padding: 0 18px; }
    .os-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .os-home-bar { display: block; width: 130px; height: 5px; margin: 14px auto 0; border-radius: 3px; background: rgba(255,255,255,0.75); }
}
/* Phone */
@media (max-width: 600px) {
    .os-device { border-radius: 34px; padding: 8px; }
    .os-cam { display: none; }
    .os-screen { border-radius: 27px; padding: 6px 12px 12px; }
    .os-status { padding: 0 8px; }
    .os-mp-slot { margin: 6px -12px 14px; }
    .os-mp-slot #masterpieceSection .gallery-header { padding: 0 14px; }
    .os-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 4px; }
    .os-icon { width: 58px; height: 58px; border-radius: 15px; }
    .os-badge { right: -5px; top: -6px; min-width: 20px; height: 20px; font-size: .66rem; }
    .os-label { font-size: .68rem; }
    .os-dock { gap: 10px; padding: 10px 12px; border-radius: 24px; }
    .os-dock .os-icon { width: 52px; height: 52px; border-radius: 14px; }
}

/* ---------- edit mode ("jiggle", admin) + icon picker ---------- */
.os-status-r { display: inline-flex; align-items: center; gap: 10px; }
.os-edit { border: 0; border-radius: 999px; padding: 3px 11px; cursor: pointer; font-size: .74rem; font-weight: 600; background: rgba(255,255,255,0.18); color: #fff; }
.os-edit:hover { background: rgba(255,255,255,0.3); }
#osView.is-editing .os-edit { background: #fff; color: #1a1030 !important; }
.os-edit-hint { margin: 6px 0 0; text-align: center; font-size: .82rem; color: #ffe6a8; }
#osView.is-editing .os-grid .os-icon, #osView.is-editing .os-dock .os-icon { animation: osJiggle .32s ease-in-out infinite alternate; }
#osView.is-editing .os-app:nth-child(2n) .os-icon { animation-delay: -.16s; }
@keyframes osJiggle { from { transform: rotate(-2.2deg); } to { transform: rotate(2.2deg); } }
.os-pen { position: absolute; left: -6px; top: -6px; z-index: 1; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #fff; color: #1a1030; font-style: normal; font-size: .75rem; font-weight: 700; box-shadow: 0 2px 6px rgba(0,0,0,0.4); }
@media (prefers-reduced-motion: reduce) { #osView.is-editing .os-icon { animation: none; } }

.os-pk { position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; padding: 16px; background: rgba(8,4,20,0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.os-pk-box { width: min(720px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-sizing: border-box; padding: 18px 20px; border-radius: 22px; color: #fff;
    background: rgba(40,28,70,0.92); border: 1px solid rgba(255,255,255,0.14); box-shadow: 0 30px 70px rgba(0,0,0,0.55); font-family: -apple-system, 'Segoe UI', 'Outfit', 'Mitr', sans-serif; }
.os-pk-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.os-pk-head h3 { margin: 0; font-size: 1.15rem; }
.os-pk-x { border: 0; background: rgba(255,255,255,0.12); color: #fff; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.os-pk-main { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; }
.os-pk-prev { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.os-pk-icon { display: block; width: 150px; height: 150px; border-radius: 36px; overflow: hidden; background: #222; box-shadow: 0 12px 26px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.18); }
.os-pk-icon img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: grab; touch-action: none; user-select: none; }
.os-pk-icon img:active { cursor: grabbing; }
.os-pk-prev small { color: rgba(255,255,255,0.65); font-size: .75rem; }
.os-pk-lab { margin: 0 0 8px; font-size: .85rem; font-weight: 600; color: rgba(255,255,255,0.8); }
.os-pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; max-height: 220px; overflow-y: auto; padding: 2px; margin-bottom: 12px; }
.os-pk-th { padding: 0; border: 2px solid transparent; border-radius: 14px; overflow: hidden; aspect-ratio: 1; cursor: pointer; background: #222; }
.os-pk-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.os-pk-th.is-on { border-color: #fff; box-shadow: 0 0 0 2px #8b5cf6; }
.os-pk-none { color: rgba(255,255,255,0.6); font-size: .85rem; margin: 0 0 12px; }
.os-pk-row { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.os-pk-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,0.22); background: rgba(255,255,255,0.1); color: #fff; border-radius: 12px; padding: 8px 14px; cursor: pointer; font: inherit; font-size: .88rem; }
.os-pk-btn:hover { background: rgba(255,255,255,0.2); }
.os-pk-btn.is-save { background: #fff; color: #1a1030; border-color: #fff; font-weight: 700; }
.os-pk-btn:disabled { opacity: .5; cursor: default; }
.os-pk-url { flex: 1; min-width: 160px; padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.22); background: rgba(0,0,0,0.3); color: #fff; font: inherit; font-size: .88rem; }
.os-pk-err { min-height: 1em; margin: 6px 0 0; color: #ffb4b4; font-size: .85rem; }
.os-pk-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.os-pk-box button:focus-visible, .os-pk-box input:focus-visible, .os-pk-btn:focus-within { outline: 2px solid #fff; outline-offset: 2px; }
@media (max-width: 600px) {
    .os-pk-main { grid-template-columns: 1fr; }
    .os-pk-icon { width: 120px; height: 120px; border-radius: 28px; }
    .os-sys { display: none; }
}

/* ---------- drag to rearrange (edit mode) ---------- */
#osView.is-editing .os-app { touch-action: none; }
#osView .os-app.is-dragging .os-icon { opacity: .25; animation: none; }
#osView .os-app.is-drop .os-icon { box-shadow: 0 0 0 3px #fff, 0 0 22px rgba(255,255,255,0.6); transform: scale(1.1); animation: none; }
#osView .os-app.is-landed .os-icon { animation: osLand .45s cubic-bezier(.2,.9,.3,1.4); }
@keyframes osLand { from { transform: scale(1.25); } to { transform: scale(1); } }
.os-ghost { transition: none !important; position: fixed; left: 0; top: 0; z-index: 6000; pointer-events: none; border-radius: 19px; overflow: hidden; box-shadow: 0 18px 36px rgba(0,0,0,0.55) !important; }
.os-ghost .os-badge, .os-ghost .os-pen { display: none; }

.os-icon img { -webkit-user-drag: none; user-select: none; }
