/*
Theme Name: EduCore
Theme URI: https://educore.gorgy.org
Author: GORGY.ORG
Author URI: https://gorgy.org
Description: The EduCore learning platform theme. Presentation only — all learning features are provided by the EduCore plugins. Block theme with light/dark modes, RTL support (Arabic), and reduced-motion support.
Requires at least: 6.8
Tested up to: 7.1
Requires PHP: 8.1
Version: 1.3.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: educore-theme
Tags: education, block-styles, full-site-editing, rtl-language-support, translation-ready, accessibility-ready, wide-blocks, custom-colors
*/

/* Logical properties only — see tools/check-logical.sh. */

:root {
	--ect-radius: var(--wp--custom--radius--md, 14px);
	--ect-ease: var(--wp--custom--motion--ease, cubic-bezier(.2, .7, .2, 1));
	--ect-dur: var(--wp--custom--motion--base, 220ms);
	color-scheme: light;
}

/* Arabic typography */
:lang(ar) body,
:lang(ar) .wp-site-blocks { font-family: var(--wp--preset--font-family--arabic); line-height: 1.85; }
:lang(ar) h1, :lang(ar) h2, :lang(ar) h3 { line-height: 1.4; letter-spacing: 0; }

/* Dark mode: swap tokens (core plugin components read the same tokens). */
html[data-theme="dark"] {
	color-scheme: dark;
	--wp--preset--color--cream: #0b1628;
	--wp--preset--color--surface: #12223a;
	--wp--preset--color--ink: #eef2f8;
	--wp--preset--color--navy: #e8eef8;
	--wp--preset--color--muted: #b5c0d2;
	--wp--preset--color--line: #2b3d5a;
	--wp--preset--color--teal: #3cc6bf;
	--wp--preset--color--teal-strong: #6fdad4;
	--wp--preset--color--gold: #e2c35a;
}
html[data-theme="dark"] .wp-element-button,
html[data-theme="dark"] .wp-block-button__link { color: #04201f; }
html[data-theme="dark"] .wp-element-button:hover,
html[data-theme="dark"] .wp-block-button__link:hover { background-color: #e8eef8; color: #0b1628; }

/* Skip link */
.ect-skip-link { position: absolute; inset-inline-start: 1rem; inset-block-start: -100px; z-index: 1000; background: var(--wp--preset--color--navy); color: #fff; padding: .6rem 1rem; border-radius: 8px; }
.ect-skip-link:focus { inset-block-start: 1rem; }
html[data-theme="dark"] .ect-skip-link { color: #0b1628; }
.ect-link-pending { color: inherit; font-style: italic; }

/* Focus visibility everywhere */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--wp--preset--color--teal); outline-offset: 2px; }

/* Header */
.ect-header { position: sticky; inset-block-start: 0; z-index: 40; background: color-mix(in srgb, var(--wp--preset--color--cream) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-block-end: 1px solid var(--wp--preset--color--line); }
.ect-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-block: .7rem; }
.ect-brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--wp--preset--color--navy); font-weight: 800; font-size: 1.35rem; }
.ect-brand__mark { inline-size: 34px; block-size: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--wp--preset--gradient--hero); color: #fff; font-size: 1rem; }
.ect-header__tools { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ect-theme-toggle { min-block-size: 40px; min-inline-size: 40px; border-radius: 999px; border: 1.5px solid var(--wp--preset--color--line); background: var(--wp--preset--color--surface); color: var(--wp--preset--color--ink); cursor: pointer; font: inherit; display: inline-grid; place-items: center; }
.ect-theme-toggle .ect-icon-dark { display: none; }
html[data-theme="dark"] .ect-theme-toggle .ect-icon-dark { display: inline; }
html[data-theme="dark"] .ect-theme-toggle .ect-icon-light { display: none; }

/* Navigation: plain list on desktop; no-JS <details> menu on mobile */
.ect-menu__list { list-style: none; display: flex; gap: .25rem; margin: 0; padding: 0; }
.ect-menu__list a { display: inline-block; padding: .55em .85em; border-radius: 999px; color: var(--wp--preset--color--ink); font-weight: 600; text-decoration: none; }
.ect-menu__list a:hover { background: color-mix(in srgb, var(--wp--preset--color--teal) 12%, transparent); }
.ect-menu { position: relative; }
.ect-menu > summary { list-style: none; cursor: pointer; display: inline-flex; min-block-size: 44px; padding-inline: 1rem; border-radius: 999px; border: 1.5px solid var(--wp--preset--color--line); align-items: center; font-weight: 600; background: var(--wp--preset--color--surface); color: var(--wp--preset--color--ink); }
.ect-menu > summary::-webkit-details-marker { display: none; }
.ect-menu[open] > .ect-menu__list { display: grid; position: absolute; inset-block-start: calc(100% + .5rem); inset-inline-start: 0; min-inline-size: 220px; padding: .5rem; background: var(--wp--preset--color--surface); border: 1px solid var(--wp--preset--color--line); border-radius: var(--ect-radius); box-shadow: var(--wp--preset--shadow--lifted); z-index: 50; }
.ect-nav-mobile { display: none; }
@media (max-width: 899px) {
	.ect-nav-desktop { display: none; }
	.ect-nav-mobile { display: block; }
	.ect-header__tools .ec-usermenu { display: none; }
}

/* Hero */
.ect-hero { position: relative; overflow: hidden; color: #fff; }
.ect-hero h1, .ect-hero p { color: #fff; }
.ect-hero .ect-eyebrow { color: #f3dd97; }
.ect-hero::after { content: ""; position: absolute; inset-block-start: -30%; inset-inline-end: -10%; inline-size: 55%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(201,162,39,.28), transparent 65%); pointer-events: none; }
html[data-theme="dark"] .ect-hero { background: linear-gradient(135deg, #07101e, #0b2a3a 60%, #0a3f3c) !important; }
.ect-hero .wp-block-button.is-style-outline .wp-block-button__link { border-color: #fff; color: #fff; background: transparent; }
.ect-eyebrow { text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; font-weight: 700; color: var(--wp--preset--color--teal-strong); }
:lang(ar) .ect-eyebrow { letter-spacing: 0; }
.ect-tagline span { display: inline-block; }

/* Feature/benefit cards */
.ect-card { background: var(--wp--preset--color--surface); border: 1px solid var(--wp--preset--color--line); border-radius: var(--ect-radius); box-shadow: var(--wp--preset--shadow--soft); transition: transform var(--ect-dur) var(--ect-ease), box-shadow var(--ect-dur) var(--ect-ease); }
.ect-card:hover { transform: translateY(-3px); box-shadow: var(--wp--preset--shadow--lifted); }
.ect-icon { inline-size: 48px; block-size: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; background: color-mix(in srgb, var(--wp--preset--color--teal) 14%, transparent); }
.ect-placeholder-note { border: 2px dashed var(--wp--preset--color--gold); border-radius: var(--ect-radius); padding: 1rem 1.25rem; color: var(--wp--preset--color--muted); }

/* Footer */
.ect-footer { background: #0B1E31; color: #F6F3E9; }
.ect-footer a { color: #faf6ee; }
.ect-footer h2, .ect-footer h3 { color: #ffffff; font-size: 1rem; }
.ect-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.ect-footer .ect-footer__initiative a { color: #f3dd97; }
html[data-theme="dark"] .ect-footer { background: #07101e; }

/* Lesson template: give the reader room */
.ect-lesson-main { padding-block: var(--wp--preset--spacing--40); }

/* Draft-legal marker created by core */
.ec-legal-draft { border-inline-start: 4px solid var(--wp--preset--color--gold); padding-inline-start: .8rem; font-weight: 600; }

/* In-page view transition (dark-mode toggle) only. Cross-document page fades were removed in 1.1.0:
   interrupted navigations (form posts) made Chromium report aborted transitions. Disabled for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
	::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }
	.ect-fade-in { animation: ect-fade .5s var(--ect-ease) both; }
}
@keyframes ect-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
	.ect-card:hover { transform: none; }
}

/* Small screens: prevent overflow */
img, video, iframe { max-inline-size: 100%; block-size: auto; }
.wp-site-blocks { overflow-x: clip; }
pre, code { overflow-wrap: anywhere; }

/* EduCore plugin blocks render without block wrappers: give their roots the wide layout width. */
.is-layout-constrained > :is(.ec-grid, .ec-subjects, .ec-catalog, .ec-course, .ec-dashboard, .ec-history, .ec-workspace, .ec-reader) {
	max-inline-size: var(--wp--style--global--wide-size);
	margin-inline: auto;
}
.is-layout-constrained > :is(.ec-grid, .ec-subjects) { inline-size: 100%; }

/* Hero content above the decorative glow */
.ect-hero > * { position: relative; z-index: 1; }

/* Content may be in a different language than the interface (e.g. English course in Arabic UI):
   let each block of user content take its direction from its own text. */
:is(.ec-outline__unit > span, .ec-prose > :is(p, li, h2, h3, h4, blockquote, figcaption), .ec-notes__list p, .ec-course-card__title, .ec-course-card__excerpt, .ec-chip, .ec-course-card__footer span, .ec-course-card__eyebrow, .wp-block-post-title, .ec-reader__title, .ec-outline a, .ec-lessons a, .ec-lessons span, .ec-unit__title, .ec-my-course h3, .ec-continue h3, .ec-table td, .ec-breadcrumb, .ec-reader__course, .ec-lead) { unicode-bidi: plaintext; }
.ec-chips { align-items: center; }
.ec-notes__form textarea { unicode-bidi: plaintext; }

/* 1.2.0 — official EduCore logo (light/dark artwork switches with the colour mode). */
.ect-logo { display: block; block-size: 36px; inline-size: auto; }
.ect-logo--dark { display: none; }
html[data-theme="dark"] .ect-logo--light { display: none; }
html[data-theme="dark"] .ect-logo--dark { display: block; }
.ect-logo-wrap { display: inline-flex; }
.ect-footer__brand { margin-block-end: .75rem; }
.ect-footer__brand img { block-size: 40px; inline-size: auto; }
@media (max-width: 600px) { .ect-logo { block-size: 30px; } }

/* ===== 1.3.0 — landing page ===== */
.ect-svg { display: block; inline-size: 100%; block-size: 100%; }

/* Hero: copy + product tour */
.ect-hero { padding-block-end: calc(var(--wp--preset--spacing--70) + 2.5rem) !important; }
.ect-hero__grid { gap: clamp(1.5rem, 4vw, 3.5rem); }
.ect-hero .ect-tagline { font-size: clamp(2.3rem, 4.6vw, 3.6rem); line-height: 1.06; margin-block: .4rem 1rem; text-wrap: balance; }
:lang(ar) .ect-hero .ect-tagline { line-height: 1.35; }
.ect-hero__lead { color: #e6eef6 !important; max-inline-size: 36rem; text-wrap: pretty; }
.ect-hero__actions { margin-block-start: 1.6rem; gap: .75rem; }
.ect-btn-gold .wp-block-button__link { background: #EBC16D; color: #0B1E31; font-weight: 700; box-shadow: 0 8px 24px rgba(235, 193, 109, .28); }
.ect-btn-gold .wp-block-button__link:hover, .ect-btn-gold .wp-block-button__link:focus-visible { background: #f3d58f; color: #0B1E31; }
html[data-theme="dark"] .ect-btn-gold .wp-block-button__link { background: #EBC16D; color: #0B1E31; }
.ect-hero .wp-block-button.is-style-outline .wp-block-button__link:hover { background: rgba(255, 255, 255, .12); }
.ect-hero__chips { list-style: none; margin: 1.6rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem .6rem; }
.ect-hero__chips li { display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .8rem; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); color: #f2f6fa; font-size: .9rem; font-weight: 600; }
.ect-hero__chips .ect-svg { inline-size: 16px; block-size: 16px; color: #43D4DA; }

/* Video card */
.ect-video { margin: 0; }
.ect-video__frame { position: relative; border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9; background: #0B1E31; box-shadow: 0 30px 70px rgba(3, 12, 24, .45), 0 0 0 1px rgba(255, 255, 255, .14); }
.ect-video video { display: block; inline-size: 100%; block-size: 100%; object-fit: cover; background: #0B1E31; }
.ect-video__play { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: flex-start; padding: 1.1rem; border: 0; cursor: pointer; color: #fff; font: inherit; background: linear-gradient(180deg, rgba(11, 30, 49, 0) 55%, rgba(11, 30, 49, .6)); }
.ect-video__play[hidden] { display: none; }
.ect-video__play > span.ect-video__pill { display: inline-flex; align-items: center; gap: .7rem; padding-block: .45rem; padding-inline: .45rem 1.1rem; border-radius: 999px; background: #EBC16D; color: #0B1E31; font-weight: 700; font-size: 1rem; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); transition: transform var(--ect-dur) var(--ect-ease), box-shadow var(--ect-dur) var(--ect-ease); }
.ect-video__icon { inline-size: 40px; block-size: 40px; border-radius: 50%; display: grid; place-items: center; padding: 11px; padding-inline-start: 13px; background: #0B1E31; color: #EBC16D; }
.ect-video__play:hover .ect-video__pill, .ect-video__play:focus-visible .ect-video__pill { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(0, 0, 0, .4); }
.ect-video__play:focus-visible { outline: 3px solid #43D4DA; outline-offset: -6px; }
.ect-video__caption { margin-block-start: .8rem; font-size: .9rem; color: #cfdde8; text-align: center; }

/* Highlights strip overlapping the hero edge */
.ect-highlights { margin-block-start: -3.2rem; position: relative; z-index: 2; }
.ect-highlights__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--wp--preset--color--surface); border: 1px solid var(--wp--preset--color--line); border-radius: 18px; box-shadow: var(--wp--preset--shadow--lifted); overflow: hidden; }
.ect-highlights__list li { padding: 1.3rem 1.4rem; display: grid; gap: .25rem; }
.ect-highlights__list li + li { border-inline-start: 1px solid var(--wp--preset--color--line); }
.ect-highlights__list strong { font-size: 2.1rem; line-height: 1; color: var(--wp--preset--color--teal); font-weight: 800; }
.ect-highlights__list span { color: var(--wp--preset--color--muted); font-size: .95rem; line-height: 1.4; }
@media (max-width: 899px) {
	.ect-highlights__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.ect-highlights__list li:nth-child(3) { border-inline-start: 0; }
	.ect-highlights__list li:nth-child(n+3) { border-block-start: 1px solid var(--wp--preset--color--line); }
}

/* Section headings */
.ect-eyebrow--dark { color: var(--wp--preset--color--teal-strong); margin-block-end: .2rem; }
html[data-theme="dark"] .ect-eyebrow--dark { color: var(--wp--preset--color--teal); }
.ect-section__title { font-size: clamp(1.7rem, 3vw, 2.3rem); margin-block: 0 .6rem; text-wrap: balance; }
.ect-section__title--sub { font-size: 1.5rem; margin-block-start: 2.5rem; }
.ect-section__lead { max-inline-size: 44rem; margin-block-end: 1.8rem; }

/* Role cards */
.ect-roles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.1rem; }
.ect-role { padding: 1.5rem 1.4rem 1.3rem; }
.ect-role h3 { font-size: 1.15rem; margin: .9rem 0 .6rem; }
.ect-role__icon { display: grid; place-items: center; inline-size: 48px; block-size: 48px; padding: 11px; border-radius: 14px; color: var(--wp--preset--color--teal-strong); background: color-mix(in srgb, var(--wp--preset--color--teal) 14%, transparent); }
html[data-theme="dark"] .ect-role__icon { color: var(--wp--preset--color--teal); }
.ect-role ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.ect-role li { position: relative; padding-inline-start: 1.1rem; color: var(--wp--preset--color--muted); font-size: .95rem; line-height: 1.5; }
.ect-role li::before { content: ""; position: absolute; inset-inline-start: 0; inset-block-start: .6em; inline-size: 6px; block-size: 6px; border-radius: 50%; background: var(--wp--preset--color--teal); }
@media (max-width: 1099px) { .ect-roles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 599px) { .ect-roles { grid-template-columns: 1fr; } }

/* Steps */
.ect-steps { list-style: none; margin: 1.5rem auto 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.4rem; counter-reset: none; }
.ect-step { position: relative; padding: 1.4rem 1.4rem 1.2rem; border-radius: var(--ect-radius); background: var(--wp--preset--color--cream); border: 1px solid var(--wp--preset--color--line); }
.ect-step__n { display: grid; place-items: center; inline-size: 40px; block-size: 40px; border-radius: 50%; background: var(--wp--preset--color--navy); color: #fff; font-weight: 800; margin-block-end: .8rem; }
html[data-theme="dark"] .ect-step__n { color: #0b1628; }
.ect-step h3 { font-size: 1.15rem; margin: 0 0 .4rem; }
.ect-step p { margin: 0; color: var(--wp--preset--color--muted); }
@media (max-width: 799px) { .ect-steps { grid-template-columns: 1fr; } }

/* Courses section link */
.ect-more { margin-block-start: 1rem; font-weight: 700; }

/* FAQ */
.ect-faq__item { border: 1px solid var(--wp--preset--color--line); border-radius: 12px; background: var(--wp--preset--color--surface); padding: 0; margin-block: .6rem 0; }
.ect-faq__item > summary { cursor: pointer; padding: 1rem 1.2rem; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.ect-faq__item > summary::-webkit-details-marker { display: none; }
.ect-faq__item > summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--wp--preset--color--teal); transition: transform var(--ect-dur) var(--ect-ease); }
.ect-faq__item[open] > summary::after { transform: rotate(45deg); }
.ect-faq__item > p { margin: 0; padding: 0 1.2rem 1.1rem; color: var(--wp--preset--color--muted); }

/* Hero stacks on small screens: video after the copy */
@media (max-width: 781px) {
	.ect-hero { padding-block-start: var(--wp--preset--spacing--60) !important; }
	.ect-hero__media { margin-block-start: .5rem; }
	.ect-video__play { padding: .7rem; }
	.ect-video__play > span.ect-video__pill { font-size: .88rem; gap: .5rem; padding-inline-end: .9rem; }
	.ect-video__icon { inline-size: 32px; block-size: 32px; padding: 9px; padding-inline-start: 10px; }
}

/* Scroll reveal (only when JS is running and motion is allowed) */
@media (prefers-reduced-motion: no-preference) {
	html.ect-js .ect-reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s var(--ect-ease), transform .5s var(--ect-ease); }
	html.ect-js .ect-reveal.is-visible { opacity: 1; transform: none; }
}
html.ect-js .ect-card.ect-reveal.is-visible:hover { transform: translateY(-3px); }

/* FAQ two columns */
.ect-faq__grid { gap: clamp(1.5rem, 4vw, 3rem); }
.ect-faq__item:first-child { margin-block-start: 0; }

/* Closing call to action */
.ect-cta { background: var(--wp--preset--gradient--hero); border: 0; color: #fff; position: relative; overflow: hidden; }
.ect-cta :is(h2, p) { color: #fff !important; }
.ect-cta p { color: #dbe6ef !important; }
.ect-cta::after { content: ""; position: absolute; inset-block-start: -40%; inset-inline-end: -8%; inline-size: 40%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(235, 193, 109, .25), transparent 65%); pointer-events: none; }
.ect-cta > * { position: relative; z-index: 1; }
.ect-cta:hover { transform: none; }
html[data-theme="dark"] .ect-cta { background: linear-gradient(135deg, #07101e, #0b2a3a 60%, #0a3f3c); }

/* ===== 1.3.1 — header polish ===== */
.ect-header__inner { flex-wrap: nowrap; }
.ect-header__tools { flex-wrap: nowrap; gap: .4rem; }
.ect-header__tools > p { margin: 0; }
.ect-header .ec-lang ul { gap: .1rem; }
.ect-header__tools .ec-usermenu { display: flex; gap: .35rem; align-items: center; }
.ect-header .ec-usermenu .ec-btn { min-block-size: 40px; padding-block: .35rem; padding-inline: .9rem; font-size: .95rem; white-space: nowrap; }
/* Signed in: "My learning" is in the account links, so the main nav does not repeat it. */
.logged-in .ect-nav-desktop a[href$="/dashboard/"],
.logged-in .ect-nav-mobile > .ect-menu__list > li > a[href$="/dashboard/"] { display: none; }
/* Compact menu: account links as a list, not pills. */
.ect-menu__account .ec-usermenu { display: grid; gap: .1rem; border-block-start: 1px solid var(--wp--preset--color--line); padding-block-start: .4rem; margin-block-start: .3rem; }
.ect-menu__account .ec-usermenu .ec-btn { justify-content: flex-start; border: 0; background: none; min-block-size: 44px; padding-inline: .85em; border-radius: 999px; font-weight: 600; font-size: 1rem; color: var(--wp--preset--color--ink); }
.ect-menu__account .ec-usermenu .ec-btn:hover { background: color-mix(in srgb, var(--wp--preset--color--teal) 12%, transparent); }
/* Signed-in users carry more header links: switch to the compact menu earlier. */
@media (min-width: 900px) and (max-width: 1199px) {
	.logged-in .ect-nav-desktop { display: none; }
	.logged-in .ect-nav-mobile { display: block; }
	.logged-in .ect-header__tools .ec-usermenu { display: none; }
}
@media (max-width: 899px) { .ect-header__inner { flex-wrap: wrap; } .ect-header__tools { flex-wrap: wrap; } .ect-header__tools .ec-usermenu { display: none; } }
