/* ==========================================================================
   ATHAR — player.css

   The Artifact Player. Everything in this file is scoped under `.art-*` so it
   can never reach into the application's own design system, and it reads its
   colours from the `--art-*` variables `themes.js` applies from the
   Artifact's own theme. The defaults below are the same warm-paper default
   the theme system produces, so an Artifact with no theme still renders.

   Only logical properties are used, so RTL is a single `dir` swap.
   ========================================================================== */

.art-frame {
  position: relative;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}

.art-player {
  --art-bg: #f5f3ef;
  --art-surface: #ffffff;
  --art-text: #16181b;
  --art-muted: #5c616b;
  --art-accent: #1e43d6;
  --art-secondary: #a4603c;
  --art-border: #ddd8cf;
  --art-quote-bg: #fbf9f4;
  --art-font-heading: Georgia, "Noto Naskh Arabic", "Times New Roman", serif;
  --art-font-body: system-ui, -apple-system, "Segoe UI", Roboto, Tahoma,
    "Noto Sans Arabic", sans-serif;
  --art-scale: 1;
  --art-density: 1;
  --art-motion: 260ms;
  --art-mode: light;

  display: flex;
  flex-direction: column;
  min-height: 460px;
  color: var(--art-text);
  background: var(--art-bg);
  font-family: var(--art-font-body);
  font-size: calc(1rem * var(--art-scale));
  line-height: 1.68;
  direction: rtl;
}

/* ------------------------------------------------------------------ header */

.art-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) calc(var(--sp-5) * var(--art-density));
  border-bottom: 1px solid var(--art-border);
  background: var(--art-surface);
}

.art-header__text {
  min-width: 0;
}

.art-header__title {
  margin: 0;
  font-family: var(--art-font-heading);
  font-size: calc(1.18rem * var(--art-scale));
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.art-header__meta {
  margin: 0.15em 0 0;
  font-size: 0.78rem;
  color: var(--art-muted);
  letter-spacing: 0.01em;
}

.art-header__position {
  margin: 0;
  flex: none;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--art-muted);
  padding-inline: var(--sp-3);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--art-text) 6%, transparent);
}

/* ------------------------------------------------------------------ progress */

.art-progress {
  position: relative;
  height: 3px;
  background: color-mix(in srgb, var(--art-text) 10%, transparent);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.art-progress__fill {
  height: 100%;
  width: calc(var(--art-progress, 0) * 1%);
  background: var(--art-accent);
  border-radius: var(--r-pill);
  transition: width var(--art-motion) var(--ease-out);
}

/* ------------------------------------------------------------------ viewport */

.art-viewport {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

/* ------------------------------------------------------------------- scenes */

.art-scene {
  max-width: 46rem;
  margin-inline: auto;
  padding: calc(var(--sp-7) * var(--art-density)) calc(var(--sp-6) * var(--art-density));
  display: flex;
  flex-direction: column;
  gap: calc(var(--sp-5) * var(--art-density));
  animation: art-scene-in var(--art-motion) var(--ease-out);
}

@keyframes art-scene-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.art-scene--hero {
  max-width: 52rem;
  min-height: 60vh;
  justify-content: center;
}

.art-scene--quote {
  max-width: 50rem;
}

.art-scene--ending {
  text-align: center;
  align-items: center;
}

.art-scene--ending .art-paragraphs,
.art-scene--ending .art-actions {
  text-align: start;
}

.art-scene__title {
  margin: 0;
  font-family: var(--art-font-heading);
  font-size: calc(1.5rem * var(--art-scale));
  font-weight: 600;
  line-height: 1.25;
}

/* -------------------------------------------------------------------- text */

.art-heading {
  margin: 0;
  font-family: var(--art-font-heading);
  font-size: calc(1.65rem * var(--art-scale));
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.art-paragraphs {
  display: flex;
  flex-direction: column;
  gap: calc(var(--sp-3) * var(--art-density));
}

.art-paragraph {
  margin: 0;
  max-width: 44rem;
  overflow-wrap: anywhere;
}

.art-paragraph--empty {
  color: var(--art-muted);
  font-style: italic;
}

.art-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--art-accent);
}

/* -------------------------------------------------------------------- image */

.art-image {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  position: relative;
}

.art-image__img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--art-border);
  background: var(--art-surface);
}

.art-image__caption {
  margin: 0;
  font-size: 0.82rem;
  color: var(--art-muted);
  text-align: center;
}

.art-zoom {
  position: absolute;
  inline-end: var(--sp-3);
  block-start: var(--sp-3);
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--art-text) 72%, transparent);
  color: var(--art-surface);
  cursor: pointer;
  font-size: 1rem;
  transition: opacity var(--art-motion) var(--ease-out);
}

.art-zoom:hover { opacity: 0.8; }

/* -------------------------------------------------------------------- gallery */

.art-gallery {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--sp-3) * var(--art-density));
}

.art-gallery__item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.art-gallery__button {
  display: block;
  padding: 0;
  border: 1px solid var(--art-border);
  border-radius: var(--r-md);
  background: var(--art-surface);
  overflow: hidden;
  cursor: zoom-in;
  transition: box-shadow var(--art-motion) var(--ease-out);
}

.art-gallery__button:hover { box-shadow: var(--sh-sm); }

.art-gallery__button:focus-visible {
  outline: 2px solid var(--art-accent);
  outline-offset: 2px;
}

.art-gallery__img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.art-gallery__caption {
  font-size: 0.78rem;
  color: var(--art-muted);
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------- quote */

.art-quote {
  margin: 0;
  padding: calc(var(--sp-6) * var(--art-density));
  border-radius: var(--r-lg);
  background: var(--art-quote-bg);
  border-inline-start: 3px solid var(--art-accent);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.art-quote__text {
  margin: 0;
  font-family: var(--art-font-heading);
  font-size: calc(1.28rem * var(--art-scale));
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.art-quote__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: 0.8rem;
  color: var(--art-muted);
}

.art-quote__source::before {
  content: "— ";
}

/* -------------------------------------------------------------------- profile */

.art-profile {
  display: grid;
  grid-template-columns: minmax(12rem, 16rem) 1fr;
  gap: calc(var(--sp-6) * var(--art-density));
  align-items: start;
}

.art-profile__portrait {
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--art-border);
  background: var(--art-surface);
  aspect-ratio: 1 / 1;
}

.art-profile__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.art-profile__text {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  min-width: 0;
}

.art-profile__name {
  margin: 0;
  font-family: var(--art-font-heading);
  font-size: calc(1.55rem * var(--art-scale));
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.art-profile__role {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--art-accent);
}

.art-facts {
  margin: calc(var(--sp-4) * var(--art-density)) 0 0;
  padding: calc(var(--sp-4) * var(--art-density)) 0 0;
  border-top: 1px solid var(--art-border);
  display: grid;
  gap: var(--sp-2);
}

.art-fact {
  display: grid;
  grid-template-columns: minmax(7rem, 10rem) 1fr;
  gap: var(--sp-3);
  align-items: baseline;
}

.art-fact__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--art-muted);
  letter-spacing: 0.02em;
}

.art-fact__value {
  margin: 0;
  font-size: 0.94rem;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------------------- timeline */

.art-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-inline-start: 2px solid var(--art-border);
}

.art-timeline__event {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: 0 0 var(--sp-5) var(--sp-5);
  border-inline-start: 3px solid transparent;
  margin-inline-start: -2px;
}

.art-timeline__event::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(-1 * var(--sp-5) - 5px);
  block-start: 0.55em;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: var(--r-pill);
  background: var(--art-accent);
  border: 2px solid var(--art-bg);
}

.art-timeline__event:last-child { padding-bottom: 0; }

.art-timeline__date {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--art-secondary);
}

.art-timeline__title {
  margin: 0;
  font-family: var(--art-font-heading);
  font-size: calc(1.02rem * var(--art-scale));
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------------------- media */

.art-media {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.art-media__element {
  width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--art-border);
  background: var(--art-surface);
}

.art-media__element[controls] { max-width: 100%; }

.art-media__title {
  margin: 0;
  font-family: var(--art-font-heading);
  font-size: calc(1.12rem * var(--art-scale));
  font-weight: 600;
}

/* -------------------------------------------------------------------- actions */

.art-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  justify-content: flex-end;
}

.art-actions .btn--art { min-width: 8rem; }

/* ------------------------------------------------------------------ interactions */

.art-interactions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  align-items: center;
}

.art-interaction-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  max-width: 34rem;
}

.art-interaction {
  appearance: none;
  border: 1px solid var(--art-border);
  background: var(--art-surface);
  color: var(--art-text);
  border-radius: var(--r-pill);
  padding: 0.55em 1.4em;
  font: inherit;
  font-size: 0.94rem;
  cursor: pointer;
  transition: background var(--art-motion) var(--ease-out),
    border-color var(--art-motion) var(--ease-out);
}

.art-interaction:hover { border-color: var(--art-accent); }

.art-interaction--reveal.is-open {
  background: var(--art-accent);
  border-color: var(--art-accent);
  color: var(--art-surface);
}

.art-interaction--navigate {
  border-color: var(--art-accent);
  color: var(--art-accent);
}

.art-interaction--restart {
  border-style: dashed;
}

.art-interaction-reveal {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height var(--art-motion) var(--ease-out),
    opacity var(--art-motion) var(--ease-out);
}

.art-interaction-reveal.is-visible {
  max-height: 24rem;
  opacity: 1;
}

.art-interaction-reveal .art-paragraph {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--art-surface);
  border: 1px solid var(--art-border);
  text-align: center;
}

.art-choice {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: 100%;
  max-width: 34rem;
}

.art-choice__legend {
  padding: 0;
  font-weight: 600;
  font-size: 0.94rem;
}

.art-choice__option {
  appearance: none;
  text-align: start;
  border: 1px solid var(--art-border);
  background: var(--art-surface);
  color: var(--art-text);
  border-radius: var(--r-md);
  padding: 0.6em 1em;
  font: inherit;
  cursor: pointer;
  transition: border-color var(--art-motion) var(--ease-out),
    background var(--art-motion) var(--ease-out);
}

.art-choice__option:hover { border-color: var(--art-accent); background: var(--art-quote-bg); }

/* ----------------------------------------------------------------- placeholder */

.art-placeholder {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: calc(var(--sp-6) * var(--art-density));
  border: 1px dashed var(--art-border);
  border-radius: var(--r-md);
  color: var(--art-muted);
  font-size: 0.9rem;
  font-style: italic;
  text-align: center;
  justify-content: center;
}

.art-placeholder__icon { font-size: 1.4rem; }

/* -------------------------------------------------------------------- nav */

.art-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) calc(var(--sp-5) * var(--art-density));
  border-top: 1px solid var(--art-border);
  background: var(--art-surface);
}

.art-nav .btn--art {
  font-family: var(--art-font-body);
}

.art-nav .btn--accent { min-width: 9rem; }

.art-footer { padding: var(--sp-2) calc(var(--sp-5) * var(--art-density)); }

/* -------------------------------------------------------------- lightbox */

.art-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-content: center;
  gap: var(--sp-4);
  padding: var(--sp-6);
  background: color-mix(in srgb, #101319 88%, transparent);
  color: #f4f5f7;
  animation: art-lightbox-in var(--art-motion) var(--ease-out);
}

@keyframes art-lightbox-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.art-lightbox__media {
  max-width: min(92vw, 60rem);
  max-height: 74vh;
  border-radius: var(--r-md);
  object-fit: contain;
  background: #101319;
}

.art-lightbox__caption {
  margin: 0;
  text-align: center;
  font-size: 0.94rem;
}

.art-lightbox__meta {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(244, 245, 247, 0.66);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.art-lightbox__close {
  position: absolute;
  inset-block-start: var(--sp-5);
  inset-inline-end: var(--sp-5);
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: var(--r-pill);
  background: rgba(244, 245, 247, 0.14);
  color: #f4f5f7;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--art-motion) var(--ease-out);
}

.art-lightbox__close:hover { background: rgba(244, 245, 247, 0.26); }

/* ----------------------------------------------------------------- pages */

.page--play .container--narrow,
.page--preview .container--narrow {
  padding-block-end: var(--sp-9);
}

.play-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-block-end: var(--sp-5);
}

.play-header__titles { min-width: 0; }

.play-header__title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
}

.play-header__subtitle {
  margin: 0.1em 0 0;
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

.preview-banner {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-block-end: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--c-accent-soft);
  color: var(--c-accent);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.preview-banner__meta {
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 899px) {
  .art-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .art-profile {
    grid-template-columns: 1fr;
  }

  .art-profile__portrait {
    max-width: 16rem;
  }

  .art-nav { flex-wrap: wrap; }
}

@media (max-width: 639px) {
  .art-scene { padding-block: var(--sp-6); }

  .art-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
  }

  .art-gallery { grid-template-columns: 1fr; }

  .art-actions { justify-content: center; }

  .art-fact { grid-template-columns: 1fr; gap: var(--sp-1); }
}

@media (prefers-reduced-motion: reduce) {
  .art-player,
  .art-scene,
  .art-interaction,
  .art-choice__option,
  .art-actions .btn,
  .art-progress__fill,
  .art-lightbox {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
  }
}

@media (forced-colors: active) {
  .art-player,
  .art-image__img,
  .art-gallery__button,
  .art-profile__portrait {
    border: 1px solid CanvasText;
  }
}
