/*
 * Persiss — Works (07): shared pieces (arch frames, 要確認 marks, live pages, logo guides)
 * and the Works index (archive-works.php, /works/type/{slug}/).
 * Case pages add works-case.css, the Websites overview adds websites.css.
 */
:root { --screen: #14120F; } /* device screen; --paper-2 lives in palette.css */
[hidden] { display: none !important; }

/* colour chips (sampled from the artwork) */
.swatch-row { display: flex; flex-wrap: wrap; gap: 8px 14px; direction: ltr; }
.swatch { display: inline-flex; align-items: center; gap: 7px; }
.swatch i { width: 16px; height: 20px; border-radius: 999px 999px 3px 3px; box-shadow: inset 0 0 0 1px rgba(var(--ink-rgb), .1); }
.swatch code { font-family: var(--f-latin); font-size: 12px; color: var(--muted); }

/* ---------- arch frame + reveal ---------- */
.frame { position: relative; aspect-ratio: 4 / 5; max-width: 100%; border-radius: var(--arch); overflow: hidden; background: var(--paper); isolation: isolate; }
.frame > img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease); }
.frame--flat { aspect-ratio: auto; border-radius: 14px; }
.frame--flat > img { height: auto; }
.ax.in .frame--flat, .ax.in.frame--flat { animation-name: flatOpen; }
@keyframes flatOpen { from { clip-path: inset(88% 8% 0 8% round 14px); } to { clip-path: inset(0 round 14px); } }
.frame--contain > img { object-fit: contain; padding: 18% 14% 14%; }
.frame--device > img { object-fit: contain; padding: 22% 6% 8%; }
.ax.in .frame, .ax.in.frame { animation: archOpen 1.15s var(--ease) backwards; animation-delay: var(--d, 0ms); }
.ax.in .frame > img, .ax.in.frame > img { animation: settle 1.5s var(--ease) backwards; animation-delay: var(--d, 0ms); }
@keyframes archOpen {
	from { clip-path: inset(88% 8% 0 8% round 999px 999px 16px 16px); }
	to { clip-path: inset(0 0 0 0 round 999px 999px 16px 16px); }
}
@keyframes settle { from { transform: scale(1.18) translateY(4%); } to { transform: none; } }

/* ---------- web: page scrolling inside an arch window ---------- */
.frame--site { background: var(--screen); container-type: size; }
.frame--site > img { height: auto; object-fit: initial; transform: translateY(0); }
.frame--site.play > img, .ax.in .frame--site.play > img, .ax.in.frame--site.play > img { animation: pageScroll var(--dur, 22s) linear infinite alternate; }
.frame--site.play.paused > img, .frame--site:hover > img, .ax.in .frame--site:hover > img { animation-play-state: paused; }
@keyframes pageScroll { 0%, 8% { transform: translateY(0); } 92%, 100% { transform: translateY(calc(-100% + 100cqh)); } }
.live { position: absolute; left: 50%; bottom: 12px; translate: -50% 0; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(20, 18, 15, .72); color: var(--on-ink); font: 700 10px/1.4 var(--f-ui); letter-spacing: .18em; }
.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-light); }

/* ---------- logo: construction lines, then the logo is revealed ---------- */
.frame--logo { background: var(--paper); }
.frame--logo > img { object-fit: contain; padding: 22% 16% 16%; }
.guides { position: absolute; inset: 0; z-index: 2; pointer-events: none; width: 100%; height: 100%; }
.guides * { fill: none; stroke: var(--accent); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 0; opacity: 0; }
.draw.in .guides * { animation: guide 2.6s var(--ease) both; animation-delay: calc(var(--d, 0ms) + var(--gd, 0ms)); }
.draw.in .frame--logo > img, .draw.in.frame--logo > img { animation: logoIn 1.6s var(--ease) backwards; animation-delay: calc(var(--d, 0ms) + 700ms); }
@keyframes guide {
	0% { stroke-dashoffset: 1; opacity: .7; }
	45% { stroke-dashoffset: 0; opacity: .7; }
	75% { opacity: .45; }
	100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes logoIn {
	from { clip-path: circle(0% at 50% 50%); filter: blur(6px); }
	to { clip-path: circle(75% at 50% 50%); filter: blur(0); }
}

/* ---------- Works index ---------- */
.head { padding-block: clamp(48px, 9svh, 96px) clamp(28px, 5svh, 48px); display: grid; gap: 14px; }
.head h1 { font-family: var(--f-ja); font-size: clamp(38px, 9vw, 76px); line-height: 1.2; }
.head__lead { color: var(--ink-soft); max-width: 34em; font-size: clamp(14.5px, 3.7vw, 16.5px); }
.head__stats { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--muted); font-size: 13px; }
.head__stats b { font-family: var(--f-latin); font-weight: 500; font-size: 22px; color: var(--ink); margin-right: 4px; font-variant-numeric: tabular-nums; }
html[lang="fa"] .head__stats b { margin-right: 0; margin-left: 4px; }

/* filter bar */
.fbar { position: sticky; top: calc(var(--nav-h) + env(safe-area-inset-top, 0px)); z-index: 40; background: rgba(var(--bg-rgb), .9); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.fbar__in { display: grid; gap: 10px; padding-block: 12px; }
.fbar__row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--paper); gap: 2px; }
.seg a { display: inline-flex; align-items: center; white-space: nowrap; min-height: 36px; padding: 0 16px; border-radius: 999px; font-size: 13.5px; font-weight: 700; letter-spacing: .05em; line-height: 1.2; color: var(--ink-soft); transition: background-color .25s ease, color .25s ease; }
.seg a[aria-current="true"] { background: var(--ink); color: var(--on-ink); }
.seg a > span:last-child { font-family: var(--f-latin); font-weight: 500; font-size: 12px; opacity: .65; margin-left: 4px; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gut-l) * -1) calc(var(--gut-r) * -1); padding-inline: var(--gut-l) var(--gut-r); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: 999px; background: transparent; box-shadow: inset 0 0 0 1.2px var(--faint); font-size: 13px; line-height: 1.2; color: var(--ink-soft); white-space: nowrap; transition: box-shadow .2s ease, color .2s ease, background-color .2s ease; }
.chip:hover { box-shadow: inset 0 0 0 1.2px var(--ink-soft); }
.chip[aria-current="true"] { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.chip small { font-family: var(--f-latin); font-size: 11.5px; margin-left: 5px; opacity: .7; }
.motion { flex: none; display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; cursor: pointer; font-size: 12px; color: var(--muted); min-height: 36px; padding: 0 4px; }
.motion i { width: 26px; height: 16px; border-radius: 999px; background: var(--faint); position: relative; transition: background-color .2s ease; }
.motion i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease); }
.motion[aria-pressed="true"] i { background: var(--accent); }
.motion[aria-pressed="true"] i::after { transform: translateX(10px); }
@media (prefers-reduced-motion: reduce) { .motion { display: none; } }
@media (max-width: 480px) {
	.seg a { padding: 0 12px; font-size: 13px; }
	.motion span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* chapters */
.chapter { padding-block: clamp(40px, 7svh, 72px) 8px; }
.chapter + .chapter { border-top: 1px solid var(--line); }
.chapter__head { display: grid; gap: 6px; margin-bottom: clamp(18px, 4svh, 32px); }
.chapter__head h2 { font-family: var(--f-ja); font-size: clamp(30px, 7.4vw, 56px); line-height: 1.25; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.chapter__head h2 em { font-family: var(--f-latin); font-style: italic; font-weight: 500; font-size: .42em; color: var(--muted); letter-spacing: .02em; }
.chapter__head p { color: var(--ink-soft); max-width: 34em; font-size: 15px; }
.cat { margin-top: clamp(28px, 5svh, 52px); }
.cat.is-first { margin-top: 0; }
.cat__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 12px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.cat__head h3 { font-family: var(--f-ja); font-size: clamp(18px, 4.6vw, 24px); }
.cat__head > span { font-family: var(--f-ui); font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }

/* grid + cards */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 14px; }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 22px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card { display: grid; gap: 12px; align-content: start; min-width: 0; text-align: left; cursor: pointer; }
.card--big { grid-column: span 2; }
@media (min-width: 760px) { .card--big .frame { aspect-ratio: 4 / 3; } }
.card:hover .frame > img { transform: scale(1.045); }
.card:hover .frame--site > img, .card:hover .frame--logo > img { transform: none; }
.card__meta { display: grid; gap: 2px; min-width: 0; }
.card__t { font-family: var(--f-ja); font-weight: 600; font-size: clamp(14.5px, 3.8vw, 17px); line-height: 1.5; }
.card--big .card__t { font-size: clamp(18px, 4.6vw, 22px); }
.card__d { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.card__row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 4px; }
.tag { font-family: var(--f-ui); font-size: 10.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.case-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: .04em; }
.case-chip::after { content: "→"; transition: transform .25s var(--ease); }
html[lang="fa"] .case-chip::after { content: "←"; }
.card:hover .case-chip::after { transform: translateX(4px); }
.mock-note { font-size: 11px; color: var(--muted); }
.cs { padding: 2px 9px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: 700 10px/1.6 var(--f-ui); letter-spacing: .16em; }
.empty { padding: 60px 0; color: var(--muted); }
.mock-foot { margin-block: clamp(60px, 10svh, 100px) clamp(40px, 8svh, 80px); font-size: 12px; color: var(--muted); }

/* viewer (works without a case page) */
.viewer { width: min(100vw, 980px); max-width: 100vw; max-height: 100svh; margin: auto; padding: 0; border: 0; background: transparent; color: var(--ink); overflow: visible; }
.viewer::backdrop { background: rgba(var(--ink-rgb), .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.viewer__box { position: relative; display: grid; gap: 14px; background: var(--bg); border-radius: 24px; padding: 16px 16px 20px; margin: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); max-height: calc(100svh - 24px); overflow: auto; }
.viewer[open] .viewer__box { animation: viewIn .55s var(--ease) both; }
@keyframes viewIn { from { clip-path: inset(30% 10% 30% 10% round 999px 999px 24px 24px); opacity: .4; } to { clip-path: inset(0 round 24px); opacity: 1; } }
.viewer__img { background: var(--paper); border-radius: 16px; display: flex; gap: 8px; align-items: center; overflow-x: auto; scroll-snap-type: x mandatory; min-height: 200px; }
.viewer__img img { flex: none; max-height: 60svh; width: auto; max-width: 100%; object-fit: contain; scroll-snap-align: center; margin-inline: auto; }
.viewer__img--site { display: block; max-height: 60svh; overflow-y: auto; background: var(--screen); }
.viewer__img--site img { max-height: none; width: 100%; }
.viewer__meta { display: grid; gap: 4px; padding-inline: 4px; }
.viewer__meta h2 { font-family: var(--f-ja); font-size: clamp(20px, 5vw, 26px); }
.viewer__meta p { color: var(--ink-soft); font-size: 14px; }
.viewer__about { color: var(--ink-soft); font-size: 14.5px; line-height: 1.85; max-width: 40em; }
.viewer__meta .swatch-row { margin-top: 6px; }
.viewer__note { font-size: 13px; margin-top: 4px; }
.viewer__note a { color: var(--accent); }
.viewer__bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding-inline: 4px; }
.viewer__nav { display: flex; gap: 8px; direction: ltr; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; background: var(--paper); font-size: 18px; display: grid; place-items: center; transition: background-color .2s ease; }
.icon-btn:hover { background: var(--paper-2); }
.viewer__close { position: absolute; top: 24px; right: 24px; z-index: 2; background: rgba(var(--bg-rgb), .92); }

/* Persian: right-to-left text inside the unchanged layout */
html[lang="fa"] :is(.card__t, .card__d, .viewer__meta h2, .viewer__meta p, .viewer__about, .viewer__note, .head__lead, .chapter__head p, .mock-foot) { direction: rtl; }

/* ---------- reduced motion: everything static and readable ---------- */
@media (prefers-reduced-motion: reduce) {
	.ax.in .frame, .ax.in.frame, .ax.in .frame > img, .ax.in.frame > img,
	.draw.in .frame--logo > img, .draw.in.frame--logo > img { animation: none !important; }
	.guides { display: none; }
	.frame--site.play > img, .ax.in .frame--site.play > img, .ax.in.frame--site.play > img { animation: none; }
	.frame--site { overflow-y: auto; }
	.live { display: none; }
	.viewer[open] .viewer__box { animation: none; }
}
.tag--brand { color: var(--accent); }
