/*
Theme Name: Maitha AlShamsi
Theme URI: https://maitha.me
Author: Maitha AlShamsi project team
Description: Lightweight bilingual block theme for Maitha.me — Beyond the Blueprint / ما وراء المخطط. Contemporary Emirati architectural editorial.
Version: 1.1.0
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 8.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: maitha
*/

/* Most styling lives in theme.json. This file holds what theme.json cannot express. */

:root { --maitha-line: rgba(114, 139, 128, 0.35); }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

:lang(ar), [dir="rtl"] { font-family: var(--wp--preset--font-family--plex-arabic); line-height: 1.9; }
:lang(ar) h1, :lang(ar) h2, :lang(ar) h3, .maitha-ar-display { font-family: var(--wp--preset--font-family--naskh); line-height: 1.5; }

a:focus-visible, button:focus-visible, .wp-element-button:focus-visible {
  outline: 3px solid var(--wp--preset--color--horizon-text);
  outline-offset: 3px;
}

.skip-link.screen-reader-text:focus { background: #F5F3EE; color: #193B3A; padding: 12px 16px; z-index: 100000; }

/* Architectural linework behind the hero */
.maitha-hero { position: relative; overflow: hidden; }
.maitha-hero::before {
  content: ""; position: absolute; inset: 0 0 0 auto; width: min(46vw, 620px); pointer-events: none;
  background-image:
    linear-gradient(var(--maitha-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--maitha-line) 1px, transparent 1px);
  background-size: 120px 120px;
  mask-image: linear-gradient(90deg, transparent, #000 40%);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%);
}
.maitha-hero > * { position: relative; }

.maitha-portrait img { aspect-ratio: 3 / 4; object-fit: cover; object-position: center 30%; width: 100%; height: auto; }

.maitha-video { position: relative; aspect-ratio: 16 / 9; width: 100%; background: #193B3A; }
.maitha-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.maitha-rule-top { border-top: 1px solid #D9D4C8; }
.maitha-milestones .wp-block-column { border-top: 1px solid #D9D4C8; padding-top: 1.25rem; }

.maitha-label { font-family: var(--wp--preset--font-family--manrope); font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; }

@media (max-width: 781px) {
  .maitha-hero::before { width: 100%; opacity: 0.5; }
}

/* ===== v1.1 dynamic layer (progressive enhancement; see assets/js/maitha.js) ===== */
.maitha-progress { position: fixed; inset: 0 0 auto 0; height: 3px; background: #B7A58B; transform-origin: 0 50%; transform: scaleX(0); z-index: 1000; pointer-events: none; }

header.wp-block-group { position: sticky; top: 0; z-index: 900; background: rgba(245, 243, 238, 0.94); -webkit-backdrop-filter: saturate(140%) blur(8px); backdrop-filter: saturate(140%) blur(8px); transition: padding .3s ease, box-shadow .3s ease; }
header.wp-block-group.is-scrolled { padding-top: .75rem !important; padding-bottom: .75rem !important; box-shadow: 0 1px 0 #D9D4C8; }
.wp-block-navigation a[aria-current="true"] { color: #193B3A; text-decoration: underline; text-decoration-color: #B7A58B; text-decoration-thickness: 2px; text-underline-offset: 6px; }
section[id] { scroll-margin-top: 88px; }

.js .maitha-reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.js .maitha-reveal.is-in { opacity: 1; transform: none; }

/* Hero puzzle */
.maitha-puzzle { position: absolute; right: clamp(-40px, 2vw, 40px); top: 50%; width: min(34vw, 420px); aspect-ratio: 1; transform: translateY(-50%); display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; z-index: 0; opacity: .9; }
.maitha-tile { --glow: 0; border: 1px solid rgba(114, 139, 128, .45); background: rgba(25, 59, 58, calc(var(--glow) * .16)); transition: background .25s ease, transform .6s cubic-bezier(.2,.7,.2,1), border-color .25s; }
.maitha-tile.is-accent { background: rgba(183, 165, 139, calc(.35 + var(--glow) * .3)); border-color: transparent; }
.maitha-tile.is-gap { border-style: dashed; border-color: rgba(183, 165, 139, .7); background: transparent; }
.maitha-tile.is-moving { transform: scale(.92); }
.maitha-hero .wp-block-columns { position: relative; z-index: 1; }
.maitha-hero .maitha-portrait { position: relative; z-index: 2; }
@media (min-width: 782px) { .maitha-hero .maitha-puzzle { right: calc(38% - 60px); } }
@media (max-width: 781px) { .maitha-puzzle { width: 70vw; top: 22%; right: -18vw; opacity: .35; pointer-events: none; } }

/* Chance Givers network */
.maitha-network { display: block; width: min(560px, 100%); margin: 0 auto 1.5rem; overflow: visible; }
.maitha-network-line { fill: none; stroke: rgba(183, 165, 139, .55); stroke-width: 1.5; stroke-dasharray: 700; stroke-dashoffset: 700; transition: stroke-dashoffset 2.4s ease .2s; }
.maitha-node { fill: #193B3A; stroke: #B7A58B; stroke-width: 1.5; transition: fill .5s ease; }
.maitha-network.is-on .maitha-network-line { stroke-dashoffset: 0; }
.maitha-network.is-on .maitha-node { fill: #F5F3EE; }

/* Video poster */
.maitha-video-poster { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; background: #193B3A center / cover no-repeat; }
.maitha-video-poster::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(25,59,58,.15), rgba(25,59,58,.55)); }
.maitha-play { position: absolute; z-index: 1; left: 50%; top: 50%; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%; background: #F5F3EE; box-shadow: 0 8px 30px rgba(0,0,0,.25); transition: transform .25s ease; }
.maitha-play::before { content: ""; position: absolute; left: 31px; top: 24px; border-left: 22px solid #193B3A; border-top: 14px solid transparent; border-bottom: 14px solid transparent; }
.maitha-video-poster:hover .maitha-play, .maitha-video-poster:focus-visible .maitha-play { transform: scale(1.08); }

/* Milestones rules draw in */
.maitha-milestones.is-armed .wp-block-column { border-top-color: transparent; position: relative; }
.maitha-milestones.is-armed .wp-block-column::before { content: ""; position: absolute; left: 0; top: -1px; height: 1px; width: 100%; background: #B7A58B; transform: scaleX(0); transform-origin: 0 50%; transition: transform 1s ease; }
.maitha-milestones.is-drawn .wp-block-column::before { transform: scaleX(1); }
.maitha-milestones.is-drawn .wp-block-column:nth-child(2)::before { transition-delay: .25s; }
.maitha-milestones.is-drawn .wp-block-column:nth-child(3)::before { transition-delay: .5s; }

.reduce-motion .maitha-reveal, .reduce-motion .maitha-tile, .reduce-motion .maitha-network-line, .reduce-motion .maitha-node { transition: none !important; }

/* v1.1 red-team fixes */
.screen-reader-text { border: 0; clip: rect(1px,1px,1px,1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute !important; width: 1px; word-wrap: normal !important; }
.has-mangrove-deep-background-color a:focus-visible, .has-mangrove-deep-background-color .wp-element-button:focus-visible, .has-mangrove-deep-background-color button:focus-visible, .maitha-video-poster:focus-visible { outline-color: #F5F3EE; }
.wp-block-navigation__responsive-container-open, .wp-block-navigation__responsive-container-close { padding: 10px; min-width: 44px; min-height: 44px; }
.maitha-footer-claim { font-family: var(--wp--preset--font-family--cormorant); font-weight: 600; line-height: 1.1; }
.maitha-hero .maitha-ar-display { text-align: right; color: #193B3A; }

/* My Story */
.maitha-lang-switch { display: inline-flex; border: 1px solid #193B3A; margin-top: 1rem; }
.maitha-lang-switch[hidden] { display: none; }
.maitha-lang-switch button { font: 600 .875rem/1 var(--wp--preset--font-family--manrope); letter-spacing: .06em; padding: .8rem 1.25rem; min-height: 44px; border: 0; background: transparent; color: #193B3A; cursor: pointer; }
.maitha-lang-switch button[lang="ar"] { font-family: var(--wp--preset--font-family--plex-arabic); letter-spacing: 0; font-size: 1rem; }
.maitha-lang-switch button[aria-pressed="true"] { background: #193B3A; color: #F5F3EE; }
.maitha-story[data-lang="en"] .maitha-lang-ar, .maitha-story[data-lang="ar"] .maitha-lang-en { display: none; }
.maitha-story[data-lang="ar"] .maitha-chapter .wp-block-columns { flex-direction: row-reverse; }
.maitha-lang-ar p { font-size: 1.1875rem; line-height: 2; }
.maitha-lang-en + .maitha-lang-ar { margin-top: 2rem; padding-top: 2rem; border-top: 1px solid #D9D4C8; }
.maitha-story[data-lang] .maitha-lang-en + .maitha-lang-ar { margin-top: 0; padding-top: 0; border-top: 0; }
.maitha-story-puzzle { position: fixed; right: 20px; bottom: 20px; z-index: 800; display: grid; grid-template-columns: repeat(2, 18px); gap: 4px; padding: 8px; background: rgba(245,243,238,.9); border: 1px solid #D9D4C8; }
.maitha-story-puzzle span { width: 18px; height: 18px; border: 1px dashed #B7A58B; transition: background .5s ease, transform .5s ease; transform: scale(.7); }
.maitha-story-puzzle span.is-set { background: #193B3A; border-style: solid; border-color: #193B3A; transform: none; }
.maitha-story-puzzle span.is-set:nth-child(2) { background: #B7A58B; border-color: #B7A58B; }
