/*
 * Links landing page. Figma "Links — Mobile v2 · Plaque hours" (390x844). Sizes are in --u, one pixel
 * of the 350px-wide arch in that frame, so the whole composition scales from small phones to large
 * screens. Text and tap targets keep px minimums.
 */
html { margin: 0; zoom: 1 !important; background: #4f0f0e; }

body.links-page {
	--w: min(100vw - 40px, 420px);
	--u: calc(var(--w) / 350);
	--top: max(71px, calc(59px + env(safe-area-inset-top)));
	--dome: calc(var(--w) * 1558 / 2641);
	--ease: cubic-bezier(.2, .8, .2, 1);
	position: relative;
	margin: 0;
	min-height: 100svh;
	overflow-x: hidden;
	color: #111;
	background: #4f0f0e;
	font-family: Vazirmatn, sans-serif;
}
.links-page *, .links-page *::before, .links-page *::after { box-sizing: border-box; }

/* Phones on their side and everything wider: the arch is as tall as the screen allows. */
@media (min-width: 600px) {
	body.links-page { --w: min(100vw - 40px, max(350px, (100svh - 92px) * .4528)); }
}

/* Background: paisley on phones, the palace ruins from 768px. */
.links-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.links-bg::before { content: ""; position: absolute; inset: 0 0 -320px; background: url('../img/links/pattern-paisley.svg') left top / 320px repeat; opacity: .65; }
@media (min-width: 768px) {
	.links-bg { background: url('../img/links/background-ruins.webp') center / cover no-repeat; }
	.links-bg::before { display: none; }
}

.links-canvas { position: relative; display: flex; flex-direction: column; align-items: center; min-height: 100svh; padding: var(--top) 0 max(7px, env(safe-area-inset-bottom)); box-sizing: border-box; }

/* ---------- Arch: cream panel cut to the dome, gold line drawn on top ---------- */
.links-arch { position: relative; display: flex; flex: 1; flex-direction: column; width: var(--w); isolation: isolate; }
.links-arch__panel {
	position: absolute;
	inset: 0;
	z-index: -2;
	background: linear-gradient(rgb(245 235 216 / .5), rgb(245 235 216 / .5)), url('../img/links/pattern-floral.svg') 0 0 / calc(443 * var(--u)) auto repeat, #f5ebd8;
	-webkit-mask: url('../img/links/arch-dome-clean.svg') top / 100% var(--dome) no-repeat, linear-gradient(#000 0 0) bottom / 100% calc(100% - var(--dome) + 1px) no-repeat;
	mask: url('../img/links/arch-dome-clean.svg') top / 100% var(--dome) no-repeat, linear-gradient(#000 0 0) bottom / 100% calc(100% - var(--dome) + 1px) no-repeat;
}
.links-arch__walls { position: absolute; z-index: -1; inset: calc(var(--dome) - 1px) 0 0; border: solid #b59a60; border-width: 0 calc(5 * var(--u)) calc(5 * var(--u)); }
.links-arch__dome { position: absolute; z-index: -1; top: 0; left: 0; width: 100%; height: var(--dome); }
.links-arch__dome g path { stroke: #b59a60; stroke-width: 75.5; stroke-dasharray: 1; }

.links-content { display: flex; flex: 1; flex-direction: column; align-items: center; width: 100%; padding: calc(79 * var(--u)) calc(16 * var(--u)) calc(19 * var(--u)); text-align: center; }
.links-logo { display: block; width: calc(120 * var(--u)); height: auto; }
.links-content h1 { margin: calc(10 * var(--u)) 0 0; color: #2a0807; font-size: calc(30 * var(--u)); font-weight: 700; line-height: 1.5; text-align: center; }
.links-content h1 span { display: block; }

.links-divider { display: flex; align-items: center; gap: calc(8 * var(--u)); width: calc(196 * var(--u)); height: calc(28 * var(--u)); margin: calc(16 * var(--u)) 0 calc(18 * var(--u)); }
.links-divider span { flex: 1; height: 1px; background: #b59a60; }
.links-divider i { color: #b58424; font-style: normal; font-size: calc(22 * var(--u)); line-height: 1; }

/* ---------- Buttons ---------- */
.links-list { display: flex; flex-direction: column; gap: calc(10 * var(--u)); width: 100%; }
.links-row { display: grid; grid-template-columns: 1fr 1fr; gap: calc(10 * var(--u)); direction: ltr; }
.links-button {
	position: relative;
	display: flex;
	direction: ltr;
	align-items: center;
	justify-content: center;
	gap: calc(10 * var(--u));
	width: 100%;
	min-width: 0;
	min-height: max(48px, calc(48 * var(--u)));
	padding: 4px calc(12 * var(--u));
	border: 1px solid rgb(79 15 14 / .65);
	border-radius: calc(12 * var(--u));
	background: #faf2e4;
	color: #111;
	font: 500 max(14px, calc(15 * var(--u)))/1.5 Vazirmatn, sans-serif;
	text-decoration: none;
	box-shadow: 0 2px 3px rgb(60 20 25 / .09);
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
	transition: background-color .2s ease, border-color .2s ease, box-shadow .25s ease, transform .25s var(--ease);
}
.links-list > .links-button { min-height: max(48px, calc(52 * var(--u))); font-weight: 700; }
.links-button > svg, .links-button > img { flex: none; width: max(20px, calc(22 * var(--u))); height: max(20px, calc(22 * var(--u))); transition: transform .35s var(--ease); }
.links-button--primary { border-color: #a98355; background: #4f0f0e; color: #fff; }
.links-button--primary img { filter: brightness(0) invert(1); }
.links-button:focus-visible, .links-social:focus-visible, .links-lang__btn:focus-visible { outline: 2px solid #a98355; outline-offset: 3px; }
@media (hover: hover) {
	.links-button:hover { border-color: #a98355; background: #f7e8d6; box-shadow: 0 6px 14px rgb(60 20 25 / .16); transform: translateY(-2px); }
	.links-button--primary:hover { border-color: #b59a60; background: #641615; }
	.links-button:hover > svg, .links-button:hover > img { transform: scale(1.14) rotate(-6deg); }
}
.links-button:active { transform: scale(.97); }

/* Icons sit at the reading start: right of the text in Persian/Arabic, left of it otherwise. */
[dir="ltr"] main .links-button > svg, [dir="ltr"] main .links-button > img, [dir="ltr"] .links-social img { order: -1; }

/* ---------- Opening hours ---------- */
.links-hours { width: 100%; margin: auto 0; padding: calc(20 * var(--u)) 0 calc(18 * var(--u)); }
.links-hours h2 { margin: 0 0 calc(10 * var(--u)); color: #4f0f0e; font-size: max(13px, calc(14 * var(--u))); font-weight: 700; line-height: 1.5; text-align: center; }
.links-hours ul { display: grid; grid-template-columns: minmax(0, 1fr); gap: calc(6 * var(--u)); margin: 0; padding: 0; list-style: none; }
.links-plaque { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: calc(6 * var(--u)); min-width: 0; aspect-ratio: 318 / 52; padding: 0 calc(41 * var(--u)); background: url('../img/links/hours-plaque.svg') center / 100% 100% no-repeat; color: #f7e8d6; font-size: max(12px, calc(14 * var(--u))); font-weight: 500; line-height: 1.3; white-space: nowrap; }
.links-plaque b { justify-self: start; font-size: max(13px, calc(16 * var(--u))); font-weight: 700; }
[dir="ltr"] .links-page .links-plaque { padding: 0 calc(32 * var(--u)); }
[dir="ltr"] .links-page .links-plaque b { font-size: max(12px, calc(14 * var(--u))); }
.links-plaque__status { display: flex; align-items: center; gap: calc(5 * var(--u)); justify-self: end; font-size: max(11px, calc(12 * var(--u))); }
.links-plaque__status i { position: relative; flex: none; width: max(6px, calc(6 * var(--u))); aspect-ratio: 1; border-radius: 50%; background: #d9a79b; }
.links-plaque.is-open .links-plaque__status i { background: #8fd6a4; }
.links-plaque .when-open, .links-plaque.is-open .when-closed { display: none; }
.links-plaque.is-open .when-open { display: inline; }

.links-social { position: relative; display: flex; align-items: center; gap: calc(8 * var(--u)); min-height: max(38px, calc(38 * var(--u))); margin-bottom: auto; padding: 0 calc(14 * var(--u)); border: 1px solid rgb(79 15 14 / .35); border-radius: 999px; color: #4f0f0e; font-size: max(12px, calc(13 * var(--u))); font-weight: 500; line-height: 1.5; text-decoration: none; transition: background-color .2s ease, border-color .2s ease; }
.links-social::after { content: ""; position: absolute; inset: -5px 0; } /* 48px tap area */
.links-social img { width: calc(18 * var(--u)); height: calc(18 * var(--u)); transition: transform .4s var(--ease); }
@media (hover: hover) {
	.links-social:hover { border-color: #a98355; background: #f7e8d6; }
	.links-social:hover img { transform: rotate(-12deg) scale(1.15); }
}

/* ---------- Language chip: top right for Persian/Arabic, top left otherwise ---------- */
.links-lang { position: absolute; z-index: 30; top: calc(12px + env(safe-area-inset-top)); inset-inline-start: 20px; }
.links-lang__btn { position: relative; display: flex; direction: ltr; align-items: center; gap: 6px; width: 80px; height: 40px; padding: 0 12px 0 8px; border: 1px solid #a98355; border-radius: 12px; background: #fffbf5; color: #4f0f0e; font: 700 13px/1.5 Vazirmatn, sans-serif; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.links-lang__btn::after { content: ""; position: absolute; inset: -4px 0; }
.links-lang__btn svg { flex: none; transition: transform .25s ease; }
.links-lang__btn span { flex: 1; }
.links-lang.is-open .links-lang__btn svg { transform: rotate(180deg); }
.links-lang img { flex: none; width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.links-lang__drop { position: absolute; top: calc(100% + 8px); inset-inline-start: 0; width: 176px; padding: 6px; border: 1px solid #a98355; border-radius: 16px; background: #fffbf5; box-shadow: 0 12px 28px rgb(40 8 10 / .3); visibility: hidden; opacity: 0; transform: translateY(-8px) scale(.96); transform-origin: top; transition: opacity .2s ease, transform .25s var(--ease), visibility .25s; }
.links-lang.is-open .links-lang__drop { visibility: visible; opacity: 1; transform: none; }
.links-lang__option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: #575757; font: 500 15px/1.4 Vazirmatn, sans-serif; text-align: start; cursor: pointer; }
.links-lang__option span { flex: 1; }
.links-lang__option svg { color: #a98355; opacity: 0; }
.links-lang__option.is-current { color: #4f0f0e; font-weight: 700; }
.links-lang__option.is-current svg { opacity: 1; }
.links-lang__option:hover, .links-lang__option:focus-visible { outline: none; background: #f7e8d6; color: #4f0f0e; }

/* Route popup: centered dialog, blurred page behind it. */
.links-route { box-sizing: border-box; width: min(90vw, 380px); padding: 56px 20px 20px; border: 2px solid #b59a60; border-radius: 20px; background: #f5ebd8; color: #4f0f0e; box-shadow: 0 12px 40px rgb(40 8 10 / .35); }
.links-route::backdrop { background: rgb(40 8 10 / .35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.links-route[open] { animation: links-dialog-enter .32s cubic-bezier(.2,.8,.2,1); }
.links-route[open]::backdrop { animation: links-backdrop-enter .32s ease; }
@keyframes links-dialog-enter { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes links-backdrop-enter { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .links-route[open], .links-route[open]::backdrop { animation: none; } }
.links-route__close { position: absolute; top: 12px; inset-inline-end: 20px; width: 36px; height: 36px; border: 1px solid rgb(79 15 14 / .65); border-radius: 50%; background: #faf2e4; color: #4f0f0e; font-size: 16px; cursor: pointer; }
.links-route__close:hover { background: #f7e8d6; border-color: #a98355; }
.links-route__branch + .links-route__branch { margin-top: 12px; }
.links-route__branch :is(summary, .links-pick) { list-style: none; }
.links-route__branch :is(summary, .links-pick).links-button { position: relative; min-height: 66px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.links-route__rosette { position: absolute; left: 32px; top: 50%; width: 28px; height: 28px; background: url('../img/pages/branches/rosette.svg') center / contain no-repeat; transform: translateY(-50%) rotate(0deg); transition: transform .25s ease; pointer-events: none; }
.links-route__branch[open] .links-route__rosette { transform: translateY(-50%) rotate(45deg); }
@media (prefers-reduced-motion: reduce) { .links-route__rosette { transition: none; } }
.links-route__branch :is(summary, .links-pick)::before { content: ""; position: absolute; inset: 0; background: url('../img/links/route-button-frame.svg') center / 100% 100% no-repeat; pointer-events: none; }
.links-route__branch :is(summary, .links-pick).links-button:hover, .links-route__branch :is(summary, .links-pick).links-button:focus-visible { color: #8b0509; filter: drop-shadow(0 2px 3px rgb(79 15 14 / .18)); }
.links-route__branch--isfahan :is(summary, .links-pick) { position: relative; padding-inline: 76px; }
.links-route__branch--hashtgerd :is(summary, .links-pick) { position: relative; padding-inline: 76px; }
.links-route__branch--hashtgerd :is(summary, .links-pick)::after { content: ""; position: absolute; right: 32px; top: 50%; width: 68px; height: 40px; transform: translateY(-50%); background: url('../img/pages/branches/hashtgerd-engraving.png') center / contain no-repeat; pointer-events: none; }
.links-route__branch--isfahan :is(summary, .links-pick)::after { content: ""; position: absolute; right: 32px; top: 50%; width: 68px; height: 40px; transform: translateY(-50%); background: url('../img/pages/branches/shah-mosque-engraving.png') center / contain no-repeat; pointer-events: none; }
.links-route__branch :is(summary, .links-pick)::-webkit-details-marker { display: none; }
.links-route__branch :is(summary, .links-pick) svg:first-child { transition: transform .2s ease; }
.links-route__branch[open] :is(summary, .links-pick) svg:first-child { transform: rotate(180deg); }
@keyframes links-route-open { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.links-route__branch[open] .links-route__apps { animation: links-route-open .3s ease; }
@media (prefers-reduced-motion: reduce) { .links-route__branch[open] .links-route__apps { animation: none; } }
.links-route__apps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.links-route__apps a { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border: 1px solid rgb(79 15 14 / .65); border-radius: 12px; background: #faf2e4; color: #111; font: 500 15px/1.6 Vazirmatn, sans-serif; text-align: center; text-decoration: none; }
.links-route__apps img { border-radius: 6px; flex: none; }
.links-route__apps a:hover { background: #f7e8d6; border-color: #a98355; }
.links-route { margin: auto; max-height: 88svh; overflow-y: auto; }
.links-route .links-button { --u: 1px; }
.links-route__title { position: absolute; top: 12px; inset-inline: 64px; margin: 0; color: #4f0f0e; font-size: 16px; font-weight: 700; line-height: 36px; text-align: center; }
@media (hover: hover) { .links-pick:hover .links-route__rosette { transform: translateY(-50%) rotate(45deg); } }
.links-call { justify-content: flex-start; min-height: 56px; padding: 0 20px; gap: 12px; }
.links-call bdi { font-size: 16px; font-weight: 700; }
.links-call span { margin-inline-start: auto; }
[dir="rtl"] .links-call { direction: rtl; }
.links-call + .links-call { margin-top: 12px; }
/* Leaving: fade back down (browsers without allow-discrete close at once). */
.links-route, .links-route::backdrop { transition: opacity .22s ease, transform .22s ease, display .22s allow-discrete, overlay .22s allow-discrete; }
.links-route:not([open]) { opacity: 0; transform: translateY(12px) scale(.97); }
.links-route:not([open])::backdrop { opacity: 0; }

/* ---------- Motion: the whole entrance is over in about 1.5s ---------- */
@keyframes links-rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes links-arch-in { from { opacity: 0; transform: translateY(40px); } }
@keyframes links-fade { from { opacity: 0; } }
@keyframes links-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes links-walls { from { clip-path: inset(0 0 100%); } to { clip-path: inset(0); } }
@keyframes links-logo { from { opacity: 0; transform: scale(.82); } }
@keyframes links-line { from { transform: scaleX(0); } }
@keyframes links-star { from { opacity: 0; transform: rotate(-180deg) scale(0); } }
@keyframes links-unfold { from { clip-path: inset(0 50%); } to { clip-path: inset(0); } }
@keyframes links-pulse { from { opacity: .7; transform: none; } to { opacity: 0; transform: scale(2.8); } }
@keyframes links-drift { to { transform: translateY(-320px); } }

@media (prefers-reduced-motion: no-preference) {
	.links-bg::before { animation: links-drift 70s linear infinite; }
	.links-arch__panel { animation: links-arch-in .6s var(--ease) backwards; }
	.links-arch__dome g path { animation: links-draw .8s .15s ease-in-out backwards; }
	.links-arch__walls { animation: links-walls .5s .85s ease-out backwards; }
	.links-logo { animation: links-logo .6s .2s var(--ease) backwards; }
	.links-content h1 span { animation: links-rise .5s .32s var(--ease) backwards; }
	.links-content h1 span + span { animation-delay: .4s; }
	.links-divider span { animation: links-line .5s .5s var(--ease) backwards; }
	.links-divider span:first-child { transform-origin: right; }
	.links-divider span:last-child { transform-origin: left; }
	[dir="rtl"] .links-divider span:first-child { transform-origin: left; }
	[dir="rtl"] .links-divider span:last-child { transform-origin: right; }
	.links-divider i { animation: links-star .6s .5s var(--ease) backwards; }
	.links-list > * { animation: links-rise .5s .52s var(--ease) backwards; }
	.links-list > :nth-child(2) { animation-delay: .6s; }
	.links-list > :nth-child(3) { animation-delay: .68s; }
	.links-hours h2 { animation: links-fade .4s .74s ease backwards; }
	.links-plaque { animation: links-unfold .6s .78s var(--ease) backwards; }
	.links-plaque + .links-plaque { animation-delay: .88s; }
	.links-plaque > * { animation: links-fade .35s 1.1s ease backwards; }
	.links-plaque.is-open .links-plaque__status i::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: links-pulse 2s 1.4s ease-out infinite; }
	.links-social { animation: links-rise .5s .95s var(--ease) backwards; }
	.links-lang { animation: links-fade .4s .6s ease backwards; }
}
@media (prefers-reduced-motion: reduce) {
	.links-page *, .links-page *::before, .links-page *::after { animation: none !important; transition: none !important; }
}

/* Branch rows in the pop-ups: everything in one flex row (rosette, arrow, city, icon, engraving), so
   nothing can overlap; left-to-right languages mirror the row. */
.links-route .links-route__branch :is(summary, .links-pick).links-button { justify-content: center; gap: 8px; padding: 4px 26px; white-space: nowrap; }
[dir="ltr"] .links-route .links-route__branch :is(summary, .links-pick).links-button { flex-direction: row-reverse; }
.links-route .links-route__branch .links-route__rosette { position: static; flex: none; width: 28px; height: 28px; margin-inline-end: auto; transform: none; }
[dir="ltr"] .links-route .links-route__branch .links-route__rosette { margin-inline: auto 0; }
.links-route .links-route__branch[open] .links-route__rosette { transform: rotate(45deg); }
.links-route .links-route__branch :is(summary, .links-pick).links-button::after { position: static; flex: 0 1 68px; min-width: 24px; margin-inline-start: auto; transform: none; }
[dir="ltr"] .links-route .links-route__branch :is(summary, .links-pick).links-button::after { margin-inline: 0 auto; }
.links-route .links-route__branch :is(summary, .links-pick) > svg, .links-route .links-pick > img { width: 20px; height: 20px; }
.links-route .links-route__branch :is(summary, .links-pick) > svg:not(:last-child) { width: 12px; }
@media (hover: hover) { .links-route .links-pick:hover .links-route__rosette { transform: rotate(45deg); } }
.links-call { white-space: nowrap; }
.links-route__apps a { min-width: 0; }

/* Narrow phones and folded phones */
@media (max-width: 359px) {
	.links-route { padding-inline: 14px; }
	.links-route__title { inset-inline: 14px 58px; font-size: 14px; }
	.links-route__close { inset-inline-end: 14px; }
	.links-route .links-route__branch :is(summary, .links-pick).links-button { gap: 5px; padding-inline: 22px; font-size: 13px; }
	.links-route .links-route__branch .links-route__rosette { width: 22px; height: 22px; }
	.links-route .links-call { gap: 8px; padding-inline: 12px; }
	.links-call bdi { font-size: 15px; }
}
@media (max-width: 309px) {
	.links-row { grid-template-columns: 1fr; }
	.links-route .links-route__branch .links-route__rosette { display: none; }
	.links-route__apps { grid-template-columns: 1fr; }
	.links-route .links-call { flex-direction: column; justify-content: center; gap: 2px; padding-block: 8px; }
	.links-route .links-call span { margin: 0; }
	html[dir] .links-page .links-plaque { padding-inline: calc(22 * var(--u)); gap: 3px; }
	html[dir] .links-page .links-plaque b { font-size: 11px; }
	html[dir] .links-page .links-plaque, html[dir] .links-page .links-plaque__status { font-size: 10.5px; }
}

/* Coming soon page (inc/soon-simple.php) */
.soon-box { display: flex; flex-direction: column; align-items: center; width: 100%; margin: auto 0; padding-bottom: calc(60 * var(--u)); }
.soon-text { max-width: 30ch; margin: 0 0 calc(28 * var(--u)); color: #4f0f0e; font-size: max(14px, calc(16 * var(--u))); line-height: 1.9; }
