/*
 * ALFIDAONE public website: software gallery (viewer dialog and the /showcase/ page list).
 * Loaded only on the pages that use it (home and /showcase/). Logical properties throughout, so Arabic (RTL) mirrors without a second sheet.
 * The viewer is built by js/showcase.js; every state is a class or an attribute (no inline styles other than CSSOM custom properties set from script).
 */

/* ---------------------------------------------------------------------------- Viewer */
html.sc-lock { overflow: hidden; }
html.sc-lock body { overflow: hidden; overscroll-behavior: none; }

.sc {
  --sc-bg: #040b18; --sc-bar: #07142a; --sc-line: rgba(143, 194, 255, .16); --sc-text: #eaf1ff; --sc-muted: #aebdd6; --sc-accent: #38bdf8; --sc-blue: #1677ff;
  --dir: 1;
  position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; min-block-size: 0;
  background: radial-gradient(900px 520px at 80% -10%, rgba(22, 119, 255, .22), transparent 62%), radial-gradient(700px 420px at 0% 110%, rgba(56, 189, 248, .1), transparent 62%), var(--sc-bg);
  color: var(--sc-text); font-family: var(--font); line-height: 1.5; -webkit-text-size-adjust: 100%;
  animation: sc-fade .22s ease both;
}
.sc[dir="rtl"] { --dir: -1; }
.sc[hidden] { display: none !important; }
.sc:focus { outline: none; }
.sc :focus-visible { outline: 3px solid var(--sc-accent); outline-offset: 2px; border-radius: 8px; }
.sc button { font: inherit; color: inherit; }

.sc-top { flex: none; display: flex; align-items: center; gap: 14px; padding: 10px clamp(12px, 2.4vw, 28px); min-block-size: 60px; background: linear-gradient(180deg, rgba(7, 20, 42, .96), rgba(7, 20, 42, .82)); border-block-end: 1px solid var(--sc-line); }
.sc-logo { flex: none; inline-size: 132px; block-size: auto; aspect-ratio: 520 / 119; }
.sc-crumb { flex: 1; min-inline-size: 0; display: flex; align-items: baseline; gap: .6em; font-size: 1rem; }
.sc-module { flex: none; color: var(--sc-accent); font-weight: 700; white-space: nowrap; max-inline-size: 40%; overflow: hidden; text-overflow: ellipsis; }
.sc-sep { flex: none; align-self: center; inline-size: 1px; block-size: 1.1em; background: var(--sc-line); }
.sc-title { min-inline-size: 0; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-tools { flex: none; display: flex; align-items: center; gap: 6px; }

.sc-btn { display: inline-grid; place-items: center; inline-size: 44px; block-size: 44px; padding: 0; border: 1px solid var(--sc-line); border-radius: 12px; background: rgba(255, 255, 255, .05); cursor: pointer; transition: background-color .2s, border-color .2s, opacity .2s; }
.sc-btn:hover { background: rgba(56, 189, 248, .16); border-color: rgba(56, 189, 248, .5); }
.sc-btn[aria-disabled="true"] { opacity: .35; cursor: default; }
.sc-btn[aria-disabled="true"]:hover { background: rgba(255, 255, 255, .05); border-color: var(--sc-line); }
.sc-btn .ico { inline-size: 22px; block-size: 22px; }
.sc-close { margin-inline-start: 6px; background: rgba(255, 255, 255, .1); }

.sc-main { flex: 1 1 0; min-block-size: 0; display: flex; padding: clamp(8px, 1.6vw, 22px) clamp(8px, 2.4vw, 32px); }
.sc-stage { flex: 1; min-inline-size: 0; min-block-size: 0; container-type: size; display: grid; place-items: center; overflow: hidden; touch-action: pan-y; -webkit-user-select: none; user-select: none; cursor: zoom-in; }
.sc-stage.is-zoomed { touch-action: none; cursor: grab; }
.sc-stage.is-dragging { cursor: grabbing; }
.sc-frame { --r: 1.6; position: relative; inline-size: 100%; aspect-ratio: var(--r); inline-size: min(100cqw, calc(100cqh * var(--r))); max-block-size: 100%; transform-origin: 50% 50%; will-change: transform; background: #0d2142; border-radius: 12px; overflow: hidden; box-shadow: 0 40px 90px -20px rgba(0, 0, 0, .75), 0 0 0 1px rgba(125, 190, 255, .2), 0 0 90px -10px rgba(22, 119, 255, .35); }
.sc-frame.is-anim { transition: transform .28s cubic-bezier(.2, .7, .2, 1); }
.sc-img { display: block; inline-size: 100%; block-size: 100%; object-fit: contain; background: #fff; }
.sc-img.is-error { display: none; }
.sc-img.is-in { animation: sc-fade .3s ease both; }
.sc-img.is-in-next { animation: sc-slide .3s cubic-bezier(.2, .7, .2, 1) both; --s: 1; }
.sc-img.is-in-prev { animation: sc-slide .3s cubic-bezier(.2, .7, .2, 1) both; --s: -1; }
@keyframes sc-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sc-slide { from { opacity: 0; transform: translateX(calc(var(--s, 1) * var(--dir) * 36px)); } to { opacity: 1; transform: none; } }

.sc-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; text-align: center; background: linear-gradient(135deg, #0d2142, #0a1a36); color: var(--sc-text); }
.sc-fallback-ico { inline-size: 56px; block-size: 56px; color: var(--sc-accent); opacity: .85; }
.sc-fallback-text { margin: 0; font-weight: 700; font-size: 1.1rem; }
.sc-fallback-title { margin: 0; color: var(--sc-muted); }
.sc-loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(4, 11, 24, .35); pointer-events: none; }
.sc-spin { inline-size: 34px; block-size: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .25); border-block-start-color: var(--sc-accent); animation: sc-rot .8s linear infinite; }
@keyframes sc-rot { to { transform: rotate(360deg); } }

.sc-bottom { flex: none; display: grid; gap: 10px; padding: 12px clamp(12px, 2.4vw, 28px) max(14px, env(safe-area-inset-bottom)); background: linear-gradient(0deg, rgba(7, 20, 42, .98), rgba(7, 20, 42, .86)); border-block-start: 1px solid var(--sc-line); }
.sc-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.sc-desc { flex: 1; min-inline-size: 0; margin: 0; color: var(--sc-muted); font-size: .98rem; line-height: 1.55; max-block-size: 3.1em; overflow: hidden; }
.sc-ctl { flex: none; display: inline-flex; align-items: center; gap: 10px; }
.sc[dir="rtl"] .sc-nav .ico { transform: none; }
.sc-count { min-inline-size: 5.5ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .04em; color: #fff; unicode-bidi: isolate; }
.sc-nav { inline-size: 48px; block-size: 48px; border-radius: 14px; background: rgba(22, 119, 255, .22); border-color: rgba(56, 189, 248, .4); }

.sc-nav-row { display: flex; align-items: center; gap: 12px; min-inline-size: 0; }
.sc-cats { flex: none; display: inline-flex; padding: 3px; gap: 3px; background: rgba(255, 255, 255, .05); border: 1px solid var(--sc-line); border-radius: 14px; }
.sc-cat { display: grid; gap: 0; min-block-size: 44px; padding: 3px 14px; border: 0; border-radius: 11px; background: transparent; cursor: pointer; text-align: start; line-height: 1.25; transition: background-color .2s; }
.sc-cat:hover { background: rgba(255, 255, 255, .08); }
.sc-cat[aria-pressed="true"] { background: linear-gradient(135deg, rgba(22, 119, 255, .55), rgba(56, 189, 248, .35)); box-shadow: inset 0 0 0 1px rgba(125, 190, 255, .5); }
.sc-cat-name { font-weight: 700; font-size: .95rem; }
.sc-cat-sub { font-size: .75rem; color: var(--sc-muted); }
.sc-mods { flex: 1; min-inline-size: 0; display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: rgba(143, 194, 255, .35) transparent; padding-block: 2px; }
.sc-mod { flex: none; min-block-size: 40px; padding: 0 16px; border: 1px solid var(--sc-line); border-radius: 99px; background: rgba(255, 255, 255, .04); cursor: pointer; white-space: nowrap; font-weight: 600; font-size: .92rem; color: var(--sc-muted); transition: background-color .2s, color .2s, border-color .2s; }
.sc-mod:hover { color: #fff; border-color: rgba(56, 189, 248, .5); }
.sc-mod[aria-current="true"] { background: var(--sc-blue); border-color: var(--sc-blue); color: #fff; }

.sc-thumbs { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; padding: 4px 2px; scrollbar-width: thin; scrollbar-color: rgba(143, 194, 255, .35) transparent; }
.sc-thumb { flex: none; inline-size: 104px; aspect-ratio: 16 / 10; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #0d2142; cursor: pointer; opacity: .62; transition: opacity .2s, border-color .2s, transform .2s; }
.sc-thumb img { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; }
.sc-thumb:hover { opacity: 1; }
.sc-thumb[aria-current="true"] { opacity: 1; border-color: var(--sc-accent); box-shadow: 0 0 18px rgba(56, 189, 248, .45); }

@media (max-width: 760px) {
  .sc-top { flex-wrap: wrap; gap: 4px 8px; min-block-size: 0; padding-block: 6px 8px; }
  .sc-logo { order: 1; inline-size: 104px; margin-inline-end: auto; }
  .sc-tools { order: 2; }
  .sc-crumb { order: 3; flex: 1 0 100%; font-size: .9rem; }
  .sc-module { max-inline-size: 45%; font-size: .85rem; }
  .sc-tools .sc-btn { inline-size: 40px; block-size: 40px; }
  .sc-tools { gap: 4px; }
  .sc-row { flex-wrap: wrap; gap: 8px 12px; }
  .sc-desc { flex-basis: 100%; order: 2; font-size: .9rem; max-block-size: 4.7em; }
  .sc-ctl { order: 1; inline-size: 100%; justify-content: space-between; }
  .sc-nav-row { flex-wrap: wrap; gap: 8px; }
  .sc-cats { inline-size: 100%; }
  .sc-cat { flex: 1; padding-inline: 10px; }
  .sc-mods { inline-size: 100%; flex-basis: 100%; }
  .sc-thumb { inline-size: 84px; }
  .sc-bottom { gap: 8px; }
}
@media (max-width: 760px) and (max-height: 700px) { .sc-thumbs { display: none; } .sc-desc { max-block-size: 3.1em; } }
@media (max-height: 520px) { .sc-thumbs, .sc-nav-row, .sc-desc { display: none; } .sc-top { flex-wrap: nowrap; padding-block: 4px; } .sc-crumb { order: 0; flex: 1; } .sc-logo { display: none; } .sc-bottom { padding-block: 6px; } .sc-row { justify-content: center; } }
@media (hover: none) and (pointer: coarse) { .sc-stage { cursor: default; } }
@media (prefers-reduced-motion: reduce) { .sc, .sc-img, .sc-img.is-in, .sc-img.is-in-next, .sc-img.is-in-prev { animation: none !important; } .sc-frame.is-anim { transition: none; } .sc-spin { animation-duration: 2.4s; } }

/* ---------------------------------------------------------------------------- /showcase/ page list */
.gal-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin-block-end: 18px; }
.gal-head h2 { font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); }
.gal-cat { margin: 0; font-weight: 700; color: var(--blue-700); }
.gal-cat span { font-weight: 400; color: var(--muted); font-size: .9rem; margin-inline-start: .4em; }
.gal-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.gal-card { display: block; block-size: 100%; text-decoration: none; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s, border-color .2s; }
.gal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--blue); color: var(--ink); }
.gal-card figure { margin: 0; display: grid; }
.gal-card img { inline-size: 100%; block-size: auto; aspect-ratio: 16 / 10; object-fit: cover; background: var(--bg); border-block-end: 1px solid var(--line); }
.gal-card figcaption { display: grid; gap: 4px; padding: 14px 16px 18px; }
.gal-card strong { font-size: 1.05rem; line-height: 1.35; }
.gal-card figcaption span { color: var(--muted); font-size: .92rem; line-height: 1.55; }
.gal-full { display: inline-block; margin: 6px 16px 0; font-size: .9rem; }
@media (prefers-reduced-motion: reduce) { .gal-card:hover { transform: none; } }
