/* =====================================================================
   55 - "ระบบในเซิร์ฟเวอร์" (pages/features.blade.php, js/ui/features.js)
   Blocks of picture / clip + points, side by side, every other one flipped.
   Everything that moves sits in the prefers-reduced-motion block at the end.
   ===================================================================== */

.ft { position: relative; }

/* ---------- jump list ---------- */
.ft-index { margin-bottom: 56px; }
.ft-filter { justify-content: center; margin-bottom: 18px; }
.ft-filter button span { opacity: .6; margin-left: 4px; font-size: .85em; }
.ft-chips {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
    margin: 0; padding: 0; list-style: none;
}
.ft-chips a {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 14px 7px 8px; border: 1px solid var(--line-strong); border-radius: 40px;
    background: rgba(255, 255, 255, .02); color: var(--text-dim); font-size: .88rem; text-decoration: none;
    transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast);
}
.ft-chips a:hover, .ft-chips a:focus-visible { color: var(--text); border-color: var(--accent-hot); background: rgba(184, 19, 27, .12); }
.ft-chips a i { color: var(--accent-hot); font-size: .85em; }
.ft-chip-n {
    display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 50%;
    background: var(--ink-700); color: var(--accent-2); font: 400 .95rem/1 var(--font-display); letter-spacing: .04em;
}

/* ---------- a block ---------- */
.ft-list { display: grid; gap: clamp(72px, 10vw, 140px); counter-reset: ft; }
.ft-item {
    position: relative; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: clamp(28px, 5vw, 64px); align-items: center; scroll-margin-top: calc(var(--nav-h) + 24px);
}
.ft-item.is-flip .ft-media { order: 2; }
.ft-item.is-textonly { grid-template-columns: minmax(0, 760px); justify-content: center; text-align: center; }
.ft-item.is-textonly .ft-meta, .ft-item.is-textonly .ft-points { justify-content: center; }
.ft-item.is-textonly .ft-points { display: inline-grid; text-align: left; }
.ft-item.is-hidden { display: none; }

/* picture / clip in a frame with crimson corners and a big number behind it */
.ft-media { position: relative; }
.ft-media::before {
    content: attr(data-num); position: absolute; top: -.42em; left: -.08em; z-index: 0;
    font: 400 clamp(6rem, 13vw, 10.5rem)/1 var(--font-display); color: transparent;
    -webkit-text-stroke: 1px rgba(214, 199, 165, .16); pointer-events: none;
}
.ft-item.is-flip .ft-media::before { left: auto; right: -.08em; }
.ft-frame {
    position: relative; z-index: 1; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius);
    background: radial-gradient(120% 120% at 30% 20%, #26262d, var(--ink-900)); box-shadow: var(--shadow), 0 0 0 1px var(--line-strong);
}
.ft-frame img, .ft-frame video, .ft-iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; display: block; }
.ft-frame::after { /* dark edge so the corners read on any picture */
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(180deg, transparent 55%, rgba(7, 7, 8, .55)), radial-gradient(130% 90% at 50% 50%, transparent 60%, rgba(0, 0, 0, .45));
}
.ft-media.is-playing .ft-frame::after { opacity: 0; }
.ft-corner { position: absolute; z-index: 2; width: 42px; height: 42px; pointer-events: none; border: 0 solid var(--accent-hot); }
.ft-corner.tl { top: -8px; left: -8px; border-top-width: 3px; border-left-width: 3px; }
.ft-corner.br { right: -8px; bottom: -8px; border-right-width: 3px; border-bottom-width: 3px; }
.ft-scan { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
    background: linear-gradient(100deg, transparent 35%, rgba(255, 255, 255, .14) 50%, transparent 65%); }

.ft-zoom, .ft-play { position: absolute; inset: 0; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; color: inherit; }
.ft-play { cursor: pointer; display: grid; place-items: center; }
.ft-zoom-hint {
    position: absolute; right: 12px; top: 12px; z-index: 2; display: grid; place-items: center; width: 36px; height: 36px;
    border-radius: 50%; background: rgba(7, 7, 8, .6); color: var(--text); opacity: 0; transition: opacity var(--dur);
}
.ft-zoom:hover .ft-zoom-hint, .ft-zoom:focus-visible .ft-zoom-hint { opacity: 1; }
.ft-play-btn {
    position: relative; z-index: 2; display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 1.6rem; box-shadow: var(--glow);
    transition: transform var(--dur) var(--ease-spring), background var(--dur-fast);
}
.ft-play-btn i { margin-left: 5px; }
.ft-play:hover .ft-play-btn, .ft-play:focus-visible .ft-play-btn { transform: scale(1.1); background: var(--accent-hot); }
.ft-play-label {
    position: absolute; z-index: 2; left: 14px; bottom: 12px; padding: 4px 10px; border-radius: 2px;
    background: rgba(7, 7, 8, .72); font-size: .82rem; color: var(--text);
}
.ft-sound {
    position: absolute; right: 12px; bottom: 12px; z-index: 3; display: grid; place-items: center; width: 40px; height: 40px;
    border: 1px solid var(--line-strong); border-radius: 50%; background: rgba(7, 7, 8, .65); color: var(--text); cursor: pointer;
    transition: background var(--dur-fast), border-color var(--dur-fast);
}
.ft-sound:hover, .ft-sound[aria-pressed="true"] { background: var(--accent); border-color: var(--accent-hot); }

/* the words */
.ft-meta { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.ft-num { font: 400 2.6rem/1 var(--font-display); color: var(--accent-hot); text-shadow: 0 0 22px rgba(220, 31, 41, .45); }
.ft-tag {
    display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border: 1px solid rgba(214, 199, 165, .3);
    border-radius: 2px; color: var(--accent-2); font-size: .8rem; text-transform: uppercase; letter-spacing: 0;
}
.ft-title {
    margin: 0 0 14px; font-size: clamp(1.55rem, 3.2vw, 2.25rem); font-weight: 800; font-stretch: var(--stretch-tight);
    line-height: 1.2; color: var(--text); text-wrap: balance;
}
.ft-summary { margin: 0 0 22px; color: var(--text-dim); font-size: 1.04rem; line-height: 1.75; text-wrap: pretty; }
.ft-points { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.ft-points li {
    position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px;
    background: var(--plate); box-shadow: var(--plate-hi); border-left: 2px solid rgba(220, 31, 41, .55); border-radius: var(--radius-sm);
    color: var(--text); line-height: 1.55;
}
.ft-points li i {
    flex: 0 0 auto; display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
    background: rgba(184, 19, 27, .18); color: var(--accent-hot); font-size: .7rem;
}

/* ---------- chapter dots (wide screens) ---------- */
.ft-rail {
    position: fixed; right: 22px; top: 50%; z-index: 30; margin: 0; padding: 0; list-style: none;
    display: none; flex-direction: column; gap: 12px; transform: translateY(-50%);
    opacity: 0; visibility: hidden; transition: opacity var(--dur), visibility var(--dur);
}
.ft-rail.is-shown { opacity: 1; visibility: visible; }
.ft-rail a { position: relative; display: block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--text-faint); background: transparent;
    transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur) var(--ease-spring); }
.ft-rail a.is-on { background: var(--accent-hot); border-color: var(--accent-hot); transform: scale(1.35); box-shadow: 0 0 12px rgba(220, 31, 41, .7); }
.ft-rail a span {
    position: absolute; right: 22px; top: 50%; transform: translate(6px, -50%); white-space: nowrap; padding: 3px 10px;
    background: rgba(7, 7, 8, .85); border: 1px solid var(--line-strong); border-radius: 2px; font-size: .78rem; color: var(--text);
    opacity: 0; pointer-events: none; transition: opacity var(--dur-fast), transform var(--dur-fast);
}
.ft-rail a:hover span, .ft-rail a.is-on span { opacity: 1; transform: translate(0, -50%); }
@media (min-width: 1300px) { .ft-rail { display: flex; } }

/* ---------- end + picture viewer ---------- */
.ft-end { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: clamp(72px, 9vw, 120px); }
.ft-lightbox {
    max-width: min(1400px, 94vw); max-height: 92vh; padding: 0; border: 0; background: transparent; overflow: visible;
}
.ft-lightbox::backdrop { background: rgba(5, 5, 6, .88); backdrop-filter: blur(6px); }
.ft-lightbox img { display: block; max-width: min(1400px, 94vw); max-height: 92vh; object-fit: contain; box-shadow: var(--shadow), 0 0 0 1px var(--line-strong); }
.ft-lightbox-close {
    position: absolute; top: -18px; right: -18px; width: 40px; height: 40px; border-radius: 50%; border: 0;
    background: var(--accent); color: #fff; cursor: pointer; box-shadow: var(--glow);
}

/* ---------- phones ---------- */
@media (max-width: 991.98px) {
    .ft-item, .ft-item.is-textonly { grid-template-columns: minmax(0, 1fr); text-align: left; }
    .ft-item.is-flip .ft-media { order: 0; }
    .ft-media::before { font-size: clamp(4.5rem, 22vw, 7rem); }
    .ft-corner { width: 30px; height: 30px; }
    .ft-corner.tl { top: -6px; left: -6px; }
    .ft-corner.br { right: -6px; bottom: -6px; }
}
@media (max-width: 575.98px) {
    .ft-chips a { font-size: .82rem; }
    .ft-play-btn { width: 66px; height: 66px; font-size: 1.3rem; }
    .ft-lightbox-close { top: 8px; right: 8px; }
}

/* ---------- admin: list thumbnails, form ---------- */
.admin-features td:nth-child(3) { min-width: 260px; }
.admin-feature-thumb { position: relative; width: 104px; aspect-ratio: 16 / 9; border-radius: 2px; overflow: hidden; background: var(--ink-700); }
.admin-feature-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-feature-kind { position: absolute; right: 4px; bottom: 4px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(7, 7, 8, .75); font-size: .65rem; }
.admin-feature-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.admin-feature-type { margin: 0; cursor: pointer; }
.admin-feature-type input { position: absolute; opacity: 0; pointer-events: none; }
.admin-feature-type span {
    display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
    font-size: .88rem; transition: border-color var(--dur-fast), background var(--dur-fast);
}
.admin-feature-type input:checked + span { border-color: var(--accent-hot); background: rgba(184, 19, 27, .14); }
.admin-feature-type input:focus-visible + span { box-shadow: var(--focus-ring); }
[data-feature-for][hidden] { display: none !important; }

/* =====================================================================
   Motion (nothing here for prefers-reduced-motion: reduce)
   Only once js/ui/features.js runs (.ft-js): without it every block simply shows.
   ===================================================================== */
@media (prefers-reduced-motion: no-preference) {
    .ft-chips li { animation: ft-chip-in .6s var(--ease-out) backwards; animation-delay: calc(var(--k, 0) * 45ms + .15s); }

    /* before it is on screen: the frame is wiped shut, the words wait below */
    .ft-js .ft-item .ft-frame { clip-path: inset(0 100% 0 0); transition: clip-path 1.1s var(--ease-in-out); }
    .ft-js .ft-item.is-flip .ft-frame { clip-path: inset(0 0 0 100%); }
    .ft-js .ft-item .ft-frame img, .ft-js .ft-item .ft-frame video { transform: scale(1.18); transition: transform 1.8s var(--ease-out); }
    .ft-js .ft-item .ft-corner { opacity: 0; transform: scale(.4); transition: opacity .5s, transform .7s var(--ease-spring); transition-delay: .75s; }
    .ft-js .ft-item .ft-corner.tl { transform-origin: top left; }
    .ft-js .ft-item .ft-corner.br { transform-origin: bottom right; }
    .ft-js .ft-item .ft-media::before { opacity: 0; transform: translateY(30px); transition: opacity 1s, transform 1.2s var(--ease-out); transition-delay: .3s; }
    .ft-js .ft-item .ft-meta, .ft-js .ft-item .ft-title, .ft-js .ft-item .ft-summary { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease-out), transform .9s var(--ease-out); }
    .ft-js .ft-item .ft-title { transition-delay: .12s; }
    .ft-js .ft-item .ft-summary { transition-delay: .22s; }
    .ft-js .ft-item .ft-points li { opacity: 0; transform: translateX(-18px); transition: opacity .6s var(--ease-out), transform .7s var(--ease-out);
        transition-delay: calc(.34s + var(--k, 0) * 90ms); }
    .ft-js .ft-item .ft-points li i { transform: scale(0); transition: transform .5s var(--ease-spring); transition-delay: calc(.5s + var(--k, 0) * 90ms); }

    .ft-js .ft-item.is-in .ft-frame { clip-path: inset(0 0 0 0); }
    .ft-js .ft-item.is-in .ft-frame img, .ft-js .ft-item.is-in .ft-frame video { transform: scale(1); }
    .ft-js .ft-item.is-in .ft-corner { opacity: 1; transform: scale(1); }
    .ft-js .ft-item.is-in .ft-media::before { opacity: 1; transform: none; }
    .ft-js .ft-item.is-in .ft-meta, .ft-js .ft-item.is-in .ft-title, .ft-js .ft-item.is-in .ft-summary, .ft-js .ft-item.is-in .ft-points li { opacity: 1; transform: none; }
    .ft-js .ft-item.is-in .ft-points li i { transform: scale(1); }
    .ft-js .ft-item.is-in .ft-scan { animation: ft-scan 1.3s .5s var(--ease-in-out) both; }

    /* hover: the picture drifts closer, the corners reach out, light sweeps once */
    .ft-js .ft-item.is-in .ft-frame img { transition: transform 1.2s var(--ease-out); }
    .ft-js .ft-media:hover .ft-frame img { transform: scale(1.06); }
    .ft-js .ft-media:hover .ft-corner { transition-delay: 0s; }
    .ft-js .ft-media:hover .ft-corner.tl { transform: translate(-4px, -4px); }
    .ft-js .ft-media:hover .ft-corner.br { transform: translate(4px, 4px); }
    .ft-js .ft-media:hover .ft-scan { animation: ft-scan 1s var(--ease-in-out); }
    .ft-points li { transition-property: opacity, transform, border-color, background; }
    .ft-js .ft-item.is-in .ft-points li:hover { transform: translateX(6px); border-left-color: var(--accent-hot); transition-delay: 0s; }

    .ft-play-btn::after { /* the play button breathes */
        content: ''; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid rgba(220, 31, 41, .55);
        animation: ft-pulse 2.2s var(--ease-out) infinite;
    }

    /* the big number slides a little slower than the page (where the browser can tie it to scrolling) */
    @supports (animation-timeline: view()) {
        .ft-js .ft-item.is-in .ft-media::before { animation: ft-drift linear both; animation-timeline: view(); animation-range: cover; }
    }

    .ft-lightbox[open] { animation: ft-zoom-in .32s var(--ease-out); }
    .ft-lightbox[open]::backdrop { animation: ft-fade .32s ease; }
    .ft-lightbox.is-closing { animation: ft-zoom-out .2s ease forwards; }
}

@keyframes ft-chip-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes ft-scan { from { opacity: 1; transform: translateX(-100%); } to { opacity: 1; transform: translateX(100%); } }
@keyframes ft-pulse { from { transform: scale(.85); opacity: 1; } to { transform: scale(1.45); opacity: 0; } }
@keyframes ft-drift { from { transform: translateY(46px); } to { transform: translateY(-46px); } }
@keyframes ft-zoom-in { from { opacity: 0; transform: scale(.92); } }
@keyframes ft-zoom-out { to { opacity: 0; transform: scale(.95); } }
@keyframes ft-fade { from { opacity: 0; } }

/* =====================================================================
   AAA pass (cinematic header: 58-cine.css): HUD frames with cut corners, labels, numbered points
   ===================================================================== */
.ft-index { margin-bottom: 34px; }
.ft-media {
    --cut: 22px;
    padding: 1px; transform: perspective(1100px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .5s var(--ease-out);
    background: linear-gradient(135deg, var(--accent-hot), rgba(255, 255, 255, .12) 35%, rgba(255, 255, 255, .05) 65%, var(--accent-hot));
    clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
    box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .8);
}
.ft-media::before { display: none; }   /* the big number moves to the words side */
.ft-frame { border-radius: 0; box-shadow: none; clip-path: polygon(calc(var(--cut) - 1px) 0, 100% 0, 100% calc(100% - var(--cut) + 1px), calc(100% - var(--cut) + 1px) 100%, 0 100%, 0 calc(var(--cut) - 1px)); }
.ft-corner { display: none; }
.ft-frame::before { /* glare that follows the pointer (cine.js sets --gx / --gy) */
    content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .4s;
    background: radial-gradient(420px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .12), transparent 60%);
}
.ft-media:hover .ft-frame::before { opacity: 1; }
.ft-hud-label {
    position: absolute; left: 30px; top: 12px; z-index: 3; display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 8px; background: rgba(7, 7, 8, .7); font-size: .66rem; font-weight: 700; color: rgba(241, 238, 232, .85); pointer-events: none;
}
.ft-hud-label::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-hot); box-shadow: 0 0 8px var(--accent-hot); }

.ft-copy { position: relative; }
.ft-copy::before { /* the big outlined number behind the words */
    content: attr(data-num); position: absolute; top: -.55em; right: 0; z-index: -1; pointer-events: none;
    font: 400 clamp(6rem, 12vw, 10rem)/1 var(--font-display); color: transparent; -webkit-text-stroke: 1px rgba(214, 199, 165, .12);
}
.ft-meta { gap: 16px; }
.ft-num { display: none; }
.ft-title { position: relative; padding-bottom: 16px; font-size: clamp(1.7rem, 3.4vw, 2.6rem); text-shadow: 0 4px 24px rgba(0, 0, 0, .6); }
.ft-title::after { content: ''; position: absolute; left: 0; bottom: 0; width: 72px; height: 3px; background: linear-gradient(90deg, var(--accent-hot), transparent); box-shadow: 0 0 12px rgba(220, 31, 41, .6); }
.ft-item.is-textonly .ft-title::after { left: 50%; margin-left: -36px; }
.ft-points li {
    display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px;
    background: linear-gradient(90deg, rgba(184, 19, 27, .1), transparent 55%), var(--plate); border-left: 0; border-radius: 0;
    clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px);
}
.ft-pt-n { color: var(--accent-hot); font-size: .8rem; font-weight: 700; }
.ft-points li i { width: 24px; height: 24px; background: transparent; border: 1px solid rgba(220, 31, 41, .5); }

.ft-end { position: relative; margin-top: clamp(90px, 11vw, 150px); padding: 48px 20px; text-align: center; overflow: hidden;
    background: radial-gradient(60% 120% at 50% 100%, rgba(184, 19, 27, .25), transparent 70%); }
.ft-end::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--accent-hot), transparent); }
.ft-end .hud-tag { justify-content: center; }
.ft-end-title { margin: 12px 0 26px; font: 400 clamp(2.4rem, 6vw, 4.2rem)/1 var(--font-display); color: #fff; letter-spacing: .02em; }
.ft-end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

@media (max-width: 991.98px) {
    .ft-copy::before { font-size: 5rem; top: -.4em; }
    .ft-media { --cut: 16px; }
}
@media (prefers-reduced-motion: no-preference) {
    .ft-js .ft-item .ft-title::after { width: 0; transition: width .9s .35s var(--ease-out); }
    .ft-js .ft-item.is-in .ft-title::after { width: 72px; }
    .ft-hud-label::before { animation: cine-blink 1.2s steps(1) infinite; }
    .ft-js .ft-item .ft-copy::before { opacity: 0; transform: translateY(30px); transition: opacity 1s .2s, transform 1.2s .2s var(--ease-out); }
    .ft-js .ft-item.is-in .ft-copy::before { opacity: 1; transform: none; }
}
