/* =========================================================
   T-151 · قوالب جاهزة: معرض بنظام الشبكة نفسه، بلا لون ولا خط خارج grid.css
   الصور والمقاطع مصوّرة من صفحات حقيقية (tools/record.py)، وهويات القوالب داخل إطارها فقط
   ========================================================= */

/* ---------- الهيرو ---------- */
.tp-hero { padding-block: clamp(24px, 4vh, 48px) 0 }
.tp-hero__body { display: grid; grid-template-columns: 1.35fr 1fr; min-block-size: calc(100svh - var(--bar) - 170px) }
.tp-hero__txt { flex-direction: column; align-items: flex-start; justify-content: center; padding: clamp(24px, 3.4vw, 56px) }
.tp-hero__txt h1 { font-family: var(--ard); font-weight: 600; font-size: clamp(34px, 4.6vw, 72px); line-height: 1.45; color: var(--t1); margin-block: 18px 22px }
.tp-hero__txt h1 .hl { white-space: nowrap }
.tp-hero__lede { font-size: 16px; color: var(--t2); max-inline-size: 50ch }
.tp-hero__acts { display: flex; flex-wrap: wrap; gap: 12px; margin-block-start: 30px }
.tp-hero__obj { position: relative; align-items: stretch; min-block-size: 420px }
.tp-note { gap: 12px; padding-inline: 22px; font-size: 13px; color: var(--t3); min-block-size: 52px }
.tp-note i { inline-size: 7px; block-size: 7px; background: var(--w); flex: none }

/* ---------- الفرز ---------- */
.tp-filter { display: flex; align-items: stretch; flex-wrap: wrap }
.tp-filter button { padding-inline: 22px; font-size: 14px; color: var(--t3); min-block-size: 56px; transition: color .2s var(--ease), background-color .2s var(--ease) }
.tp-filter button[aria-pressed="true"] { background: var(--w); color: var(--ink); --l: var(--w) }
.tp-filter__count { margin-inline-start: auto; padding-inline: 22px; font-size: 13px; color: var(--t3) }

/* ---------- البطاقات ---------- */
.tp-grid { display: grid; grid-template-columns: 1fr 1fr }
.tp-card { display: flex; flex-direction: column; align-items: stretch; color: var(--t1) }
.tp-card[hidden] { display: none }
.tp-card__shot { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; background: var(--ink) }
.tp-card__shot img, .tp-card__shot video { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; object-position: top center; transition: transform .5s var(--ease), opacity .3s var(--ease) }
.tp-card__shot video { opacity: 0 }
.tp-card.is-playing .tp-card__shot video { opacity: 1 }
.tp-card__tag { position: absolute; inset-block-end: 12px; inset-inline-start: 12px; display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; background: var(--ink); color: var(--t1); font-size: 12px; box-shadow: 0 0 0 1px var(--line-2) }
.tp-card__tag i { inline-size: 0; block-size: 0; border-block: 4px solid transparent; border-inline-end: 7px solid var(--w) }
.tp-card__cap { display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 16px; padding: 16px 22px; border-block-start: 1px solid var(--line-s); transition: background-color .2s var(--ease) }
.tp-card__cap b { font-size: 11px; font-weight: 600; color: var(--t4); letter-spacing: .04em }
.tp-card__name { font-family: var(--ard); font-weight: 600; font-size: clamp(20px, 1.9vw, 28px); line-height: 1.4; color: var(--t1) }
.tp-card__for { display: block; font-family: var(--ar); font-weight: 400; font-size: 13px; line-height: 1.6; color: var(--t3) }
.tp-card__go { font-size: 14px; color: var(--t2); white-space: nowrap }
.tp-card__go i { font-style: normal; font-family: var(--lat); margin-inline-start: 8px }
@media (hover: hover) and (pointer: fine) {
  .tp-card:hover .tp-card__shot img { transform: scale(1.015) }
  .tp-card:hover .tp-card__cap { background: rgba(255, 255, 255, .05) }
  .tp-filter button:not([aria-pressed="true"]):hover { background: rgba(255, 255, 255, .05); color: var(--w) }
}

.tp-more { flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 32px; padding: clamp(22px, 3vw, 44px); color: var(--t1); transition: background-color .2s var(--ease) }
.tp-more[hidden] { display: none }
.tp-more__t { font-family: var(--ard); font-weight: 600; font-size: clamp(26px, 3vw, 46px); line-height: 1.45 }
.tp-more__t .hl { display: table; margin-block-start: 8px }
@media (hover: hover) and (pointer: fine) { .tp-more:hover { background: rgba(255, 255, 255, .05) } }

/* فسيفساء الانكشاف والانتقال: خانات حبر بدقة 16×10، حادة بلا تنعيم */
.tp-mos { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; image-rendering: pixelated; pointer-events: none; z-index: 2 }

/* ---------- كيف نطبّقه ---------- */
.tp-how__body { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-auto-rows: minmax(170px, auto) }
.tp-how__obj { grid-row: span 2; position: relative; align-items: stretch; min-block-size: 380px }

/* ---------- التالي والذيل ---------- */
.tp-bye { margin-block-start: clamp(72px, 11vh, 128px); padding-block-end: 40px }
.tp-bye__body { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-auto-rows: minmax(110px, auto) }
.tp-bye__obj { grid-row: span 2; position: relative; align-items: stretch; min-block-size: 360px }
.tp-bye__fine { grid-column: 2 / 4; padding: 18px 24px; font-size: 13px; line-height: 1.8; color: var(--t3) }
.tp-bye .legal .cell:nth-child(odd) { grid-column: 1 / 2 }
.tp-bye .legal .cell:nth-child(even) { grid-column: 2 / 4 }

/* ---------- العارض ---------- */
html.tp-lock { overflow: hidden }
.tp-dlg {
  position: fixed; inset: 0; inline-size: 100%; block-size: 100dvh; max-inline-size: none; max-block-size: none; margin: 0; padding: 0; border: 0; overflow: hidden; color: var(--t2);
  background-color: var(--ink);
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px), linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 72px 72px; background-position: center top;
}
.tp-dlg::backdrop { background: var(--ink) }
.tp-dlg[open] { display: grid; grid-template-rows: var(--bar) minmax(0, 1fr); animation: swap .24s var(--ease) both }
.tp-dlg__head { display: flex; align-items: stretch }
.tp-dlg__head .cell { min-block-size: var(--bar); padding-inline: 20px; font-size: 14px }
.tp-dlg__count { color: var(--t3); font-size: 13px !important }
.tp-dlg__title { flex: 1; color: var(--t1); font-family: var(--ard); font-weight: 600 }
.tp-dlg__close { color: var(--t1); gap: 10px }
.tp-dlg__close svg { inline-size: 18px; block-size: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round }
.tp-dlg__body { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 380px); min-block-size: 0 }
.tp-stage { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-block-size: 0 }
.tp-media { position: relative; display: flex !important; align-items: center; justify-content: center; padding: clamp(10px, 2vw, 28px); min-block-size: 0; overflow: hidden }
.tp-media__box { position: relative; aspect-ratio: 16 / 10; inline-size: 100%; max-block-size: 100%; max-inline-size: calc((100dvh - var(--bar) - var(--cell) - 56px) * 1.6); box-shadow: 0 0 0 1px var(--line-2); background: var(--ink) }
.tp-media__box img, .tp-media__box video { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; object-position: top center; display: block }
.tp-media__box [hidden] { display: none }
.tp-play { position: absolute; inset-block-end: 14px; inset-inline-start: 14px; display: inline-flex; align-items: center; gap: 12px; block-size: 52px; padding-inline: 20px; background: var(--ink); color: var(--w); box-shadow: 0 0 0 1px var(--line-2); font-size: 15px; font-weight: 500; transition: transform 160ms var(--ease) }
.tp-play i { inline-size: 0; block-size: 0; border-block: 6px solid transparent; border-inline-end: 10px solid var(--w) }
.tp-play:active { transform: scale(.97) }
.tp-tools { display: flex; align-items: stretch }
.tp-tools .cell { justify-content: center; min-block-size: var(--cell) }
.tp-tools__seg { padding-inline: 20px; font-size: 14px; color: var(--t3); transition: color .2s var(--ease), background-color .2s var(--ease) }
.tp-tools__seg[aria-pressed="true"] { color: var(--t1); background: rgba(255, 255, 255, .08) }
.tp-tools__pause { padding-inline: 20px; font-size: 14px; color: var(--t1) }
.tp-tools__pause[hidden] { display: none }
.tp-tools__gap { flex: 1 }
.tp-info { display: flex; flex-direction: column; min-block-size: 0; overflow-y: auto }
.tp-info__top { padding: clamp(20px, 2.2vw, 32px); flex: 1 }
.tp-info h2 { font-family: var(--ard); font-weight: 600; font-size: clamp(34px, 3.4vw, 52px); line-height: 1.35; color: var(--t1); margin-block-start: 10px }
.tp-info__line { font-size: 15px; color: var(--t2); margin-block-start: 14px }
.tp-info__h { font-size: 13px; color: var(--t3); margin-block-start: 24px }
.tp-info__built { margin-block-start: 8px }
.tp-info__built li { position: relative; padding-block: 9px; padding-inline-start: 18px; font-size: 14px; line-height: 1.6; color: var(--t1); border-block-end: 1px solid var(--line) }
.tp-info__built li::before { content: ""; position: absolute; inset-inline-start: 0; inset-block-start: 18px; inline-size: 7px; block-size: 7px; background: var(--w) }
.tp-info__fine { font-size: 12px; line-height: 1.7; color: var(--t3); margin-block-start: 16px }
.tp-info .tp-cta, .tp-info .tp-live { align-self: stretch; inline-size: 100% }
.tp-info .tp-cta { justify-content: space-between; padding-inline: 22px; min-block-size: 68px; flex: none; background: var(--w); color: var(--ink); --l: var(--w); font-family: var(--ard); font-weight: 600; font-size: 18px }
.tp-info .tp-live { justify-content: space-between; padding-inline: 22px; min-block-size: 54px; flex: none; color: var(--t1); font-size: 14px }
.tp-cta i, .tp-live i { font-style: normal; font-family: var(--lat) }
@media (hover: hover) and (pointer: fine) {
  .tp-dlg__close:hover, .tp-tools .cell:hover, .tp-live:hover { background: rgba(255, 255, 255, .05); color: var(--w) }
}

/* ---------- تابلت ---------- */
@media (max-width: 1100px) {
  .bar__nav .cell { padding-inline: 14px }
  .tp-how__body, .tp-bye__body { grid-template-columns: 1fr 1fr }
  .tp-how__obj, .tp-bye__obj { grid-column: 1 / -1; grid-row: auto; min-block-size: 320px }
  .tp-bye__fine { grid-column: 1 / -1 }
  .tp-bye .legal .cell:nth-child(n) { grid-column: auto }
}
@media (max-width: 900px) {
  .tp-hero__body { grid-template-columns: 1fr; min-block-size: 0 }
  .tp-hero__obj { min-block-size: 0; aspect-ratio: 1 / .7 }
  .tp-dlg { overflow-y: auto }
  .tp-dlg[open] { display: block }
  .tp-dlg__head { position: sticky; inset-block-start: 0; z-index: 2; background: var(--ink) }
  .tp-dlg__body { display: block }
  .tp-media { padding: 10px }
  .tp-media__box { max-inline-size: none }
  .tp-info { overflow: visible }
  .tp-info .tp-cta { position: sticky; inset-block-end: 0; z-index: 3 }
}

/* ---------- جوال ---------- */
@media (max-width: 768px) {
  .tp-hero__txt { padding: 22px 20px }
  .tp-hero__txt h1 { font-size: clamp(32px, 9vw, 40px) }
  .tp-hero__acts .btn { flex: 1 1 100%; justify-content: space-between }
  .tp-note { align-items: flex-start; padding-block: 14px; line-height: 1.7 }
  .tp-note i { margin-block-start: 8px }
  .tp-filter button { flex: 1 1 auto; padding-inline: 12px; font-size: 13px; min-block-size: 48px }
  .tp-filter__count { display: none }
  .tp-grid { grid-template-columns: 1fr }
  .tp-card__cap { padding: 14px 16px; column-gap: 12px }
  .tp-card__go span { display: none }
  .tp-how__body, .tp-bye__body { grid-template-columns: 1fr }
  .tp-how__obj, .tp-bye__obj { min-block-size: 0; aspect-ratio: 1 / .8 }
  .tp-bye__fine { padding: 16px 20px }
  .tp-tools__seg, .tp-tools__pause { padding-inline: 14px; font-size: 13px }
  .tp-dlg__head .cell { padding-inline: 14px }
  .tp-dlg__close span { display: none }
}

@media (prefers-reduced-motion: reduce) {
  .tp-card__shot img, .tp-play { transition: none }
  .tp-card:hover .tp-card__shot img { transform: none }
  .tp-play:active { transform: none }
}
@media (max-width: 768px) { .tp-more .tp-card__go span { display: inline } }
