/* ==========================================================================
   Phone home: the link stack, made better
   ========================================================================== */

.phone { display: none; }

@media (max-width: 899px) {
	.phone {
		position: relative;
		z-index: 2;
		display: flex;
		flex-direction: column;
		gap: 14px;
		min-height: 100dvh;
		padding: 0 16px calc(28px + var(--safe-b));
	}
}

.phone__status {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 4px;
	margin: 0 -16px;
	padding: calc(6px + var(--safe-t)) 12px 6px 16px;
	background: linear-gradient(180deg, rgb(0 0 0 / 0.92), rgb(0 0 0 / 0.65));
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	border-bottom: 1px solid var(--line-soft);
	font-family: var(--f-display);
	font-size: 11px;
	letter-spacing: 0.1em;
	color: var(--red);
	text-shadow: var(--text-glow);
}

/* The logo in miniature, top left: wordmark over the square, the globe spinning in it. */
.phone__mark { display: inline-flex; align-items: center; margin-right: auto; }
.logo3d--status { --box: 30px; }
.logo3d--status .logo3d__word {
	margin-right: calc(var(--box) * -0.42);
	font-size: 14px;
	letter-spacing: 0.08em;
	background: linear-gradient(180deg, #fff 0 46%, #ffd3d3 52%, #ff8f8f 70%, #fff 100%);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	text-shadow: none;
	filter: drop-shadow(0 0 4px rgb(255 69 69 / calc(0.7 * var(--glow-k))));
}
.logo3d--status .logo3d__box { box-shadow: 0 0 8px rgb(255 69 69 / calc(0.5 * var(--glow-k))); }
html:not(.is-booting) .logo3d--status .logo3d__word { animation: mark-glitch 9s steps(1) 4s infinite; }
@keyframes mark-glitch {
	0%, 94%, 100% { transform: none; filter: drop-shadow(0 0 4px rgb(255 69 69 / calc(0.7 * var(--glow-k)))); }
	95% { transform: translateX(-2px) skewX(-10deg); filter: drop-shadow(2px 0 0 var(--red)) drop-shadow(-2px 0 0 #6ff); }
	97% { transform: translateX(2px); filter: drop-shadow(-2px 0 0 var(--red)) drop-shadow(1px 0 0 #fff); }
}
.phone__icon-btn { position: relative; display: grid; place-items: center; width: 34px; height: 30px; }
.phone__icon-btn .pd-icon { width: 24px; }
.phone__icon-btn .badge { position: absolute; top: -4px; right: -2px; min-width: 16px; height: 16px; font-size: 9px; }
.phone__icon-btn.is-signed-in::after { content: ''; position: absolute; right: 4px; bottom: 2px; width: 7px; height: 7px; background: #42ff7a; box-shadow: 0 0 6px #42ff7a; }
.phone__time { margin-right: 4px; font-family: var(--f-num); font-size: 13px; letter-spacing: 0.05em; }

.phone__hero {
	display: grid;
	justify-items: center;
	gap: 2px;
	padding: 2px 0 0;
	text-align: center;
}

.phone__eye {
	width: min(56vw, 240px);
	margin-bottom: 10px;
	filter: drop-shadow(0 0 14px rgb(255 69 69 / calc(0.9 * var(--glow-k)))) drop-shadow(0 0 40px rgb(255 69 69 / calc(0.5 * var(--glow-k))));
	animation: eye-bob 6s ease-in-out infinite;
}
@keyframes eye-bob { 50% { transform: translateY(-8px); } }

.phone__name { display: flex; justify-content: center; margin: 0 0 4px; }
.phone__tagline {
	font-family: var(--f-display);
	font-size: clamp(16px, 5.2vw, 24px);
	text-transform: uppercase;
	text-shadow: var(--text-glow);
	text-wrap: balance;
}
.phone__subline { color: var(--pink); font-size: 20px; }

/* Now playing card: hidden until a song is started from MUSIC (assets/js/os/phone.js). */
.phone__now[hidden] { display: none; }
.phone__now {
	display: grid;
	grid-template-columns: 58px 1fr 72px 44px;
	align-items: center;
	gap: 12px;
	padding: 10px 10px 10px 8px;
	border: 2px solid var(--red);
	background:
		repeating-linear-gradient(0deg, rgb(255 69 69 / 0.05) 0 1px, transparent 1px 3px),
		rgb(10 0 0 / 0.88);
	box-shadow: var(--glow);
}
.phone__now-play { position: relative; display: grid; place-items: center; width: 58px; height: 58px; color: var(--white); }
.phone__now-disc .pd-icon { width: 58px; }
.phone__now-glyph {
	position: absolute;
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	background: var(--black);
	border: 2px solid var(--white);
}
.phone__now-glyph .pd-glyph { width: 12px; height: 12px; }
.phone__now.is-playing .phone__now-disc { animation: spin 1.8s linear infinite; }
.phone__now-info { display: grid; gap: 3px; min-width: 0; color: var(--white); text-decoration: none; }
.phone__now-title { font-family: var(--f-display); font-size: 14px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone__now-meta { color: var(--pink); font-size: 17px; line-height: 1; }
.phone__now-bar { height: 4px; background: var(--red-ink); }
.phone__now-bar i { display: block; width: 0; height: 100%; background: var(--red); box-shadow: var(--glow); }
.phone__now-viz { width: 72px; height: 40px; }
.phone__now-next { display: grid; place-items: center; height: 44px; border: 2px solid var(--red-deep); color: var(--white); }
.phone__now-next .pd-glyph { width: 16px; height: 16px; }

/* The links */
.phone__links { display: grid; gap: 12px; }

.phone-link {
	--d: 0ms;
	position: relative;
	display: grid;
	grid-template-columns: 54px 1fr 28px;
	grid-template-rows: auto auto;
	align-items: center;
	gap: 0 14px;
	min-height: 78px;
	padding: 10px 14px 10px 10px;
	border: 2px solid var(--red);
	border-radius: 2px;
	background: linear-gradient(100deg, rgb(255 69 69 / 0.95) 0%, rgb(160 24 24 / 0.8) 34%, rgb(24 2 2 / 0.92) 100%);
	box-shadow: var(--glow);
	color: var(--white);
	text-decoration: none;
	overflow: hidden;
	isolation: isolate;
	animation: link-in 0.6s var(--ease-out) both;
	animation-delay: var(--d);
	transition: transform 0.15s var(--ease-out), box-shadow 0.2s;
}

/* Scanlines and the sweeping light from the original buttons. */
.phone-link::before {
	content: '';
	position: absolute;
	inset: 0;
	z-index: -1;
	background: repeating-linear-gradient(0deg, rgb(0 0 0 / 0.16) 0 1px, transparent 1px 3px);
}
.phone-link::after {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	left: -60%;
	width: 50%;
	z-index: -1;
	background: linear-gradient(110deg, transparent, rgb(255 255 255 / 0.32), transparent);
	transform: skewX(-12deg);
	animation: link-sweep 5.5s ease-in-out infinite;
	animation-delay: calc(var(--d) * 3 + 1s);
}

.phone-link:active { transform: scale(0.975); box-shadow: var(--glow-strong); }

.phone-link__icon { grid-row: 1 / 3; width: 54px; filter: drop-shadow(0 2px 0 rgb(0 0 0 / 0.5)); }
.phone-link__label {
	align-self: end;
	font-family: var(--f-display);
	font-size: 21px;
	line-height: 1.05;
	text-transform: uppercase;
	text-shadow: 0 2px 0 rgb(0 0 0 / 0.35);
}
.phone-link__sub { align-self: start; color: var(--blush); font-size: 18px; line-height: 1.1; }
.phone-link__label:only-of-type { grid-row: 1 / 3; align-self: center; }
.phone-link__go { grid-column: 3; grid-row: 1 / 3; display: grid; place-items: center; width: 28px; height: 28px; border: 1.5px solid rgb(255 255 255 / 0.6); }
.phone-link__go .pd-glyph { width: 14px; height: 14px; }

/* App links glow a little brighter than plain links. */
.phone-link:not([data-app]) { background: linear-gradient(100deg, rgb(60 6 6 / 0.95), rgb(14 1 1 / 0.92)); }

@keyframes link-in {
	from { opacity: 0; transform: translateY(18px) scale(0.98); filter: brightness(2); }
}
@keyframes link-sweep {
	0%, 70% { left: -60%; }
	100% { left: 130%; }
}

.phone__foot { display: grid; gap: 10px; margin-top: 8px; }
.phone__ticker {
	overflow: hidden;
	border-block: 1.5px solid var(--red-deep);
	padding: 8px 0;
	color: var(--red);
	font-family: var(--f-display);
	font-size: 12px;
	letter-spacing: 0.1em;
	white-space: nowrap;
	text-shadow: var(--text-glow);
}
.phone__ticker span { display: inline-block; animation: ticker-phone 18s linear infinite; }
@keyframes ticker-phone { to { transform: translateX(-50%); } }
.phone__legal { color: var(--pink); font-size: 17px; text-align: center; }

/* --------------------------------------------------------------------------
   Make it move. Everything below switches itself off with reduced motion
   (base.css), and waits for the BIOS screen to finish.
   -------------------------------------------------------------------------- */

/* The logo powers on like a tube, the tagline drops in, then glitches every so often. */
html:not(.is-booting) .phone__name { animation: hero-on 0.9s var(--ease-out) 0.05s backwards; }
html:not(.is-booting) .phone__tagline { animation: hero-up 0.6s var(--ease-out) 0.35s backwards, tag-glitch 7s steps(1) 3s infinite; }
html:not(.is-booting) .phone__subline { animation: hero-up 0.6s var(--ease-out) 0.5s backwards; }

@keyframes hero-on {
	0% { opacity: 0; transform: scale(1.35, 0.02); filter: brightness(4); }
	35% { opacity: 1; transform: scale(0.97, 1.08); filter: brightness(2.2); }
	55% { transform: translateX(-4px) skewX(5deg); }
	70% { transform: translateX(3px); }
	100% { transform: none; filter: none; }
}
@keyframes hero-up {
	from { opacity: 0; transform: translateY(10px); filter: blur(3px) brightness(2); }
}
@keyframes tag-glitch {
	0%, 90%, 100% { transform: none; text-shadow: var(--text-glow); clip-path: none; }
	91% { transform: translateX(-3px) skewX(-8deg); text-shadow: 3px 0 var(--red), -3px 0 var(--blush); }
	93% { transform: translateX(4px); text-shadow: -4px 0 var(--red), 2px 0 var(--white); clip-path: inset(0 0 45% 0); }
	95% { transform: translateX(-1px); text-shadow: 2px 0 var(--red); clip-path: inset(50% 0 0 0); }
	97% { transform: none; text-shadow: var(--text-glow); clip-path: none; }
}

/* Cards power on as they scroll into view (os/phone.js adds .has-reveal, then .is-on per card). */
/* Kept low in specificity (:where) so the tap glitch below still wins once a card is on. */
.phone.has-reveal :is(.phone__cal, .phone-link):not(.is-on) { opacity: 0; animation: none; }
:where(html:not(.is-booting) .phone.has-reveal) .is-on {
	animation: card-on 0.55s var(--ease-out) var(--d, 0ms) backwards; /* backwards, so :active still presses once it is on */
}
html:not(.is-booting) .phone.has-reveal .phone-link.is-on .phone-link__icon { animation: icon-pop 0.65s var(--ease-out) calc(var(--d, 0ms) + 180ms) backwards; }

@keyframes card-on {
	0% { opacity: 0.3; transform: scale(0.92, 0.04); filter: brightness(3); }
	30% { opacity: 1; transform: scale(1.01, 1.08); filter: brightness(2); }
	45% { transform: translateX(-5px) skewX(6deg); }
	55% { transform: translateX(4px) skewX(-4deg); opacity: 0.6; }
	70% { transform: none; opacity: 1; filter: brightness(1.3); }
	100% { transform: none; filter: none; }
}
@keyframes icon-pop {
	from { opacity: 0; transform: scale(0.4) rotate(-14deg); }
	60% { opacity: 1; transform: scale(1.14) rotate(3deg); }
}

/* Opening an app: the card tears, splits its colours and flashes. */
.phone :is(.phone-link, .phone__cal).is-launching { animation: launch 0.45s linear; }
.phone .is-launching :is(.phone-link__label, .phone__cal-title) { animation: rgb-split 0.45s steps(3); }

@keyframes launch {
	0% { transform: scale(0.97); clip-path: inset(0); filter: brightness(2.2); }
	15% { transform: scale(0.97) translateX(6px); clip-path: inset(12% 0 48% 0); }
	30% { transform: scale(0.97) translateX(-5px); clip-path: inset(52% 0 8% 0); filter: brightness(1.6) saturate(1.4); }
	45% { transform: scale(0.98) translateX(3px); clip-path: inset(0 0 70% 0); }
	60% { transform: scale(0.99); clip-path: inset(0); filter: brightness(1.8); }
	100% { transform: none; clip-path: inset(0); filter: none; }
}
@keyframes rgb-split {
	0%, 100% { transform: none; text-shadow: 0 2px 0 rgb(0 0 0 / 0.35); }
	33% { transform: translateX(2px); text-shadow: -4px 0 var(--red), 4px 0 var(--white); }
	66% { transform: translateX(-2px); text-shadow: 3px 0 var(--red), -3px 0 var(--blush); }
}
