/* STACK Apps landing pages. Presentation only: colours come from the theme (--brand-color, --cta-color). */

body.stack-landing #post-content { max-width: none; padding: 0; }

.stack-app { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

.stack-hero { text-align: center; padding: 72px 0 40px; }
.stack-hero__icon img { width: 96px; height: 96px; border-radius: 22%; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.stack-hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: 1.05; margin: 20px 0 12px; }
.stack-hero__tagline { font-size: 1.25rem; max-width: 640px; margin: 0 auto 24px; opacity: .75; }

.stack-section { padding: 56px 0; border-top: 1px solid rgba(0,0,0,.06); }
.stack-section > h2, .stack-section__copy > h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.15; margin: 0 0 16px; }
.stack-section--intro, .stack-section--cta { text-align: center; }
.stack-section--intro p, .stack-section--cta p, .stack-section--prose { max-width: 680px; margin-left: auto; margin-right: auto; }
.stack-section--prose { max-width: 680px; }

/* Split: copy + screenshot */
.stack-section--split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; }
.stack-section__media { display: flex; justify-content: center; }
.stack-section--media-left .stack-section__media { order: -1; }
.stack-shot img { max-width: 100%; height: auto; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.15); }

/* Buttons */
.stack-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 24px; }
.stack-section--split .stack-buttons { justify-content: flex-start; }
.stack-button { display: inline-block; padding: 12px 26px; border-radius: 999px; border: 2px solid var(--cta-color, var(--brand-color, #007AFF)); color: var(--cta-color, var(--brand-color, #007AFF)); text-decoration: none; font-weight: 600; }
.stack-button--primary { background: var(--cta-color, var(--brand-color, #007AFF)); color: #fff; }

/* Feature grid */
.stack-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 32px; }
.stack-feature { background: rgba(0,0,0,.03); border-radius: 16px; padding: 24px; }
.stack-feature__icon img { width: 40px; height: 40px; border-radius: 10px; }
.stack-feature h3 { margin: 12px 0 6px; font-size: 1.05rem; }
.stack-feature p { margin: 0; opacity: .75; }

/* Gallery */
.stack-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 32px; margin-top: 32px; align-items: end; }
.stack-gallery__item { margin: 0; text-align: center; }
.stack-gallery__item figcaption { margin-top: 12px; font-size: .9rem; opacity: .7; }

/* Device frames (CSS only; the screenshot fills the screen) */
.stack-device { position: relative; background: #111; box-shadow: 0 12px 40px rgba(0,0,0,.25); max-width: 100%; margin: 0 auto; }
.stack-device__screen { overflow: hidden; background: #000; line-height: 0; }
.stack-device__screen img { width: 100%; height: auto; display: block; }

.stack-device--iphone { width: 280px; padding: 10px; border-radius: 44px; }
.stack-device--iphone .stack-device__screen { border-radius: 34px; }
.stack-device--iphone::before { content: ""; position: absolute; top: 18px; left: 50%; width: 84px; height: 24px; margin-left: -42px; background: #000; border-radius: 14px; z-index: 2; }

.stack-device--ipad { width: 100%; max-width: 520px; padding: 14px; border-radius: 28px; }
.stack-device--ipad .stack-device__screen { border-radius: 16px; }

.stack-device--mac { width: 100%; max-width: 620px; padding: 12px 12px 14px; border-radius: 14px 14px 0 0; margin-bottom: 18px; }
.stack-device--mac .stack-device__screen { border-radius: 4px; }
.stack-device--mac::after { content: ""; position: absolute; left: -6%; right: -6%; bottom: -18px; height: 18px; background: linear-gradient(#cfd0d4, #a7a8ad); border-radius: 0 0 18px 18px; }

@media (max-width: 760px) {
	.stack-section--split { grid-template-columns: 1fr; gap: 28px; }
	.stack-section--media-left .stack-section__media { order: 0; }
	.stack-section--split .stack-buttons { justify-content: center; }
	.stack-section--split { text-align: center; }
}

/* Devices showcase: Mac behind, iPad centre, iPhone overlapping at the front */
/* WordPress wraps a group's blocks in an inner container; let the device items take part in the layout directly. */
.stack-devices > .wp-block-group__inner-container, .stack-gallery > .wp-block-group__inner-container { display: contents; }
.stack-devices { position: relative; display: flex; justify-content: center; align-items: flex-end; min-height: 120px; }
.stack-devices .stack-devices__item--mac { flex: 0 1 62%; order: 0; }
.stack-devices .stack-devices__item--ipad { flex: 0 1 44%; margin-left: -12%; position: relative; z-index: 1; order: 1; }
.stack-devices .stack-devices__item--iphone { flex: 0 1 22%; margin-left: -8%; position: relative; z-index: 2; order: 3; }
.stack-devices .stack-devices__item .stack-device { width: 100%; max-width: none; }
.stack-devices .stack-devices__item .stack-device--iphone { padding: 4px; border-radius: 18px; }
.stack-devices .stack-devices__item .stack-device--iphone .stack-device__screen { border-radius: 14px; }
.stack-devices .stack-devices__item .stack-device--iphone::before { display: none; }

/* [apps] shortcode */
.stack-apps { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.stack-apps__item { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; padding: 48px 0; border-top: 1px solid rgba(0,0,0,.06); }
.stack-apps--rows .stack-apps__item:nth-child(even) .stack-apps__media { order: 2; }
.stack-apps__media { display: flex; justify-content: center; }
.stack-apps__icon img { width: 56px; height: 56px; border-radius: 22%; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.stack-apps__copy h2 { margin: 12px 0 8px; font-size: clamp(1.4rem, 3.5vw, 2rem); }
.stack-apps__copy h2 a { color: inherit; text-decoration: none; }
.stack-apps__copy p { opacity: .8; }
.stack-apps__copy .stack-buttons { justify-content: flex-start; }
.stack-apps--cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
.stack-apps--cards .stack-apps__item { grid-template-columns: 1fr; gap: 20px; padding: 24px; border: 1px solid rgba(0,0,0,.08); border-radius: 16px; }
@media (max-width: 760px) {
	.stack-apps__item { grid-template-columns: 1fr; gap: 24px; }
	.stack-apps--rows .stack-apps__item:nth-child(even) .stack-apps__media { order: 0; }
}
.stack-archive-title { max-width: 1080px; margin: 48px auto 0; padding: 0 24px; }

/* Hero composition (main + up to two extra screenshots; frames inferred from image shape) */
.stack-devices--hero { margin: 40px auto 0; max-width: 960px; }
.stack-devices .stack-devices__item--none { flex: 0 1 30%; position: relative; z-index: 1; order: 2; }
.stack-devices .stack-devices__item:only-child { margin-left: 0; }
.stack-devices .stack-devices__item--mac:only-child { flex-basis: 78%; }
.stack-devices .stack-devices__item--ipad:only-child { flex-basis: 56%; }
.stack-devices .stack-devices__item--iphone:only-child { flex-basis: 240px; }

/* Pattern layout (core blocks + classes) */
.stack-teaser { text-align: center; font-size: 1.25rem; max-width: 640px; margin: 0 auto 8px; opacity: .75; }
.stack-teaser:empty { display: none; }
.stack-section .wp-block-columns { gap: 48px; align-items: center; }
.stack-section--features .wp-block-columns { align-items: stretch; margin-top: 24px; }
.stack-feature { height: 100%; background: rgba(0,0,0,.03); border-radius: 16px; padding: 24px; }
.stack-feature h3 { margin-top: 0; }
.wp-block-column > .stack-devices__item { display: flex; justify-content: center; }
.stack-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 32px; margin-top: 24px; align-items: end; }
.stack-section--devices .stack-devices { margin-top: 0; }
.stack-section--intro > *, .stack-section--cta > * { text-align: center; }
.stack-section--cta .stack-buttons { justify-content: center; }

/* Closing "Get the app" band: full width, grey, centred (icon, heading, text, button) */
body.stack-landing { overflow-x: clip; }
.stack-cta { margin: 56px calc(50% - 50vw) 0; padding: 96px 24px; background: var(--stack-cta-bg, #f0f0f0); text-align: center; }
.stack-cta__icon img { width: 96px; height: 96px; border-radius: 22%; box-shadow: 0 4px 16px rgba(0,0,0,.15); display: inline-block; }
.stack-cta h2 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.15; margin: 24px 0 12px; }
.stack-cta p { max-width: 520px; margin: 0 auto; font-size: 1.1rem; opacity: .85; }
.stack-cta .stack-buttons { justify-content: center; margin-top: 28px; }
.stack-button__glyph { vertical-align: -3px; margin-left: 8px; }

/*
 * Device mosaic (wide screens): the devices sit staggered like a Photomator-style collage, not in one row.
 * Mac high on the right, iPad lower left, iPhone below between them. Narrow screens keep the overlapping row above.
 */
@media (min-width: 821px) {
	:is(.stack-devices, .stack-gallery) { display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: auto; align-items: center; justify-items: center; gap: 0; min-height: 0; padding: 24px 0 8px; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item { flex: none; margin: 0; width: 100%; order: 0; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item--mac    { grid-column: 6 / 13; grid-row: 1 / 3; align-self: start; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item--ipad   { grid-column: 1 / 6;  grid-row: 2 / 4; margin-top: 14%; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item--iphone { grid-column: 7 / 10; grid-row: 3 / 5; width: 72%; margin-top: 3%; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item--none   { grid-column: 9 / 13; grid-row: 3 / 5; width: 80%; }
	/* A single device stays centred. */
	:is(.stack-devices, .stack-gallery) .stack-devices__item:only-child { grid-column: 3 / 11; grid-row: auto; width: 100%; margin: 0; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item--iphone:only-child { grid-column: 5 / 9; width: 70%; }
	.stack-devices--hero > .stack-devices__item--iphone:only-child { grid-column: 5 / 9; }
}

/*
 * Two devices instead of three: the composition adapts to whichever devices are present.
 * (Uses :has(); where it is unsupported the three-device layout above simply applies.)
 */
@media (min-width: 821px) {
	/* Mac + iPhone: Mac large on the left, iPhone overlapping its lower right */
	:is(.stack-devices, .stack-gallery):not(:has(.stack-devices__item--ipad)) .stack-devices__item--mac:not(:only-child)    { grid-column: 1 / 10; grid-row: 1 / 4; align-self: start; }
	:is(.stack-devices, .stack-gallery):not(:has(.stack-devices__item--ipad)) .stack-devices__item--iphone:not(:only-child) { grid-column: 8 / 12; grid-row: 2 / 5; width: 62%; margin-top: 10%; position: relative; z-index: 2; }
	/* iPad + iPhone: same composition */
	:is(.stack-devices, .stack-gallery):not(:has(.stack-devices__item--mac)) .stack-devices__item--ipad:not(:only-child)    { grid-column: 1 / 10; grid-row: 1 / 4; margin-top: 0; align-self: start; }
	:is(.stack-devices, .stack-gallery):not(:has(.stack-devices__item--mac)) .stack-devices__item--iphone:not(:only-child)  { grid-column: 8 / 12; grid-row: 2 / 5; width: 62%; margin-top: 10%; position: relative; z-index: 2; }
	/* Mac + iPad: Mac on the right, iPad overlapping its lower left */
	:is(.stack-devices, .stack-gallery):not(:has(.stack-devices__item--iphone)) .stack-devices__item--mac:not(:only-child)  { grid-column: 4 / 13; grid-row: 1 / 4; align-self: start; }
	:is(.stack-devices, .stack-gallery):not(:has(.stack-devices__item--iphone)) .stack-devices__item--ipad:not(:only-child) { grid-column: 1 / 7; grid-row: 2 / 5; margin-top: 12%; position: relative; z-index: 2; }
}

/* Narrow screens: the devices stack in a column with space between them. */
@media (max-width: 820px) {
	:is(.stack-devices, .stack-gallery) { display: flex; flex-direction: column; align-items: center; gap: 32px; padding: 16px 0; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item { flex: none; margin: 0; width: 100%; order: 0; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item--ipad   { width: 84%; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item--iphone { width: 52%; max-width: 240px; }
	:is(.stack-devices, .stack-gallery) .stack-devices__item--none   { width: 70%; }
}
