/*
Theme Name: ArshPress Base
Theme URI: https://arshpress.example
Description: RTL-first base theme of the ArshPress distribution and front-end foundation of pages built with arsh/* blocks. Colors, type and spacing come from the shared design tokens (tokens.css) through theme.json.
Author: ArshPress
Version: 0.2.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: arsh-base
Requires at least: 7.0
Requires PHP: 8.2
*/

/*
 * Rules: tokens only (no raw colors), logical properties only, no !important, budget in tools/theme-budget.php.
 * Theme-local variables use the --ab- prefix. Looks (arsh-look-*) re-skin by overriding --arsh-* and --ab-* on body.
 */
:root { --ab-wide: 1200px; --ab-header-h: 68px; --ab-header-ink: var(--arsh-ink); }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-block-start: calc(var(--ab-header-h) + var(--arsh-space-3)); }
body {
  margin: 0; background: var(--arsh-surface); color: var(--arsh-ink);
  font-family: var(--arsh-font); font-size: var(--arsh-text-md); line-height: 1.8;
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
.arsh-scheme-auto { color-scheme: light dark; }
.arsh-scheme-dark, .arsh-dark { color-scheme: dark; }
.arsh-look-default { --ab-look: default; } /* hook: another look adds .arsh-look-<name> rules here */
img, video, svg { max-width: 100%; height: auto; }
a { color: var(--arsh-primary); text-underline-offset: 3px; }
a:hover { color: var(--arsh-primary-hover); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--arsh-primary); outline-offset: 2px;
}
h1, h2, h3, h4 { line-height: 1.4; font-weight: 800; margin: 0 0 var(--arsh-space-4); text-wrap: balance; }
h1 { font-size: clamp(1.875rem, 1.4rem + 2vw, 3rem); line-height: 1.25; }
h2 { font-size: clamp(1.5rem, 1.25rem + 1vw, 2.125rem); line-height: 1.35; }
h3 { font-size: clamp(1.125rem, 1.05rem + 0.5vw, 1.375rem); line-height: 1.45; }
p, ul, ol, blockquote, figure, pre, table { margin: 0 0 var(--arsh-space-4); }
p { text-wrap: pretty; }

.screen-reader-text {
  position: absolute; inline-size: 1px; block-size: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip-path: inset(50%); border: 0; white-space: nowrap;
}
.skip-link:focus {
  position: fixed; inset-block-start: var(--arsh-space-3); inset-inline-start: var(--arsh-space-3); z-index: 100;
  inline-size: auto; block-size: auto; margin: 0; padding: var(--arsh-space-3) var(--arsh-space-4); clip-path: none;
  background: var(--arsh-primary); color: var(--arsh-on-primary); border-radius: var(--arsh-radius-sm); text-decoration: none;
}
.site-wrap { overflow-x: clip; }
.arsh-wrap { max-inline-size: var(--ab-wide); margin-inline: auto; padding-inline: var(--arsh-space-4); }
.site-main:focus { outline: 0; } /* tabindex=-1 target of the skip link, never keyboard-reachable on its own */

/* ------------------------------------------------------------ announcement */
.arsh-announce { background: var(--arsh-deep); color: var(--arsh-on-deep); text-align: center; font-size: var(--arsh-text-sm); }
.arsh-announce__text { margin: 0; padding: var(--arsh-space-2) var(--arsh-space-4); }
.arsh-announce a { color: inherit; font-weight: 700; }

/* ------------------------------------------------------------------ header */
.arsh-header {
  position: sticky; inset-block-start: var(--wp-admin--admin-bar--height, 0px); z-index: 50;
  background: color-mix(in srgb, var(--arsh-surface) 90%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-block-end: 1px solid var(--arsh-line); color: var(--ab-header-ink);
  transition: box-shadow var(--arsh-duration) var(--arsh-ease), background-color var(--arsh-duration) var(--arsh-ease);
}
.arsh-header__inner {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--arsh-space-3) var(--arsh-space-5);
  max-inline-size: var(--ab-wide); margin-inline: auto; padding-inline: var(--arsh-space-4);
  min-block-size: var(--ab-header-h); transition: min-block-size var(--arsh-duration) var(--arsh-ease);
}
.arsh-header.is-scrolled { --ab-header-h: 56px; box-shadow: var(--arsh-shadow-2); }
.site-title { margin: 0; font-size: var(--arsh-text-lg); font-weight: 800; }
.site-title a, .arsh-header .custom-logo-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
.arsh-header .custom-logo { max-block-size: 40px; inline-size: auto; }
.arsh-nav { margin-inline-start: auto; }
.arsh-menu, .arsh-footer__menu { display: flex; flex-wrap: wrap; gap: var(--arsh-space-1); margin: 0; padding: 0; list-style: none; }
.arsh-menu a {
  display: inline-flex; align-items: center; min-block-size: var(--arsh-target); padding-inline: var(--arsh-space-3);
  border-radius: var(--arsh-radius-sm); color: inherit; text-decoration: none; font-weight: 500;
  transition: background-color var(--arsh-duration) var(--arsh-ease);
}
.arsh-menu a:hover, .arsh-menu .current-menu-item > a { background: var(--arsh-surface-2); color: var(--arsh-primary); }
.arsh-menu .menu-item-has-children { position: relative; }
.arsh-menu .sub-menu {
  position: absolute; inset-inline-start: 0; inset-block-start: 100%; z-index: 5; min-inline-size: 14rem; margin: 0; padding: var(--arsh-space-2);
  list-style: none; display: none; background: var(--arsh-surface); color: var(--arsh-ink); border: 1px solid var(--arsh-line);
  border-radius: var(--arsh-radius-md); box-shadow: var(--arsh-shadow-3);
}
.arsh-menu .menu-item-has-children:hover > .sub-menu, .arsh-menu .menu-item-has-children:focus-within > .sub-menu { display: block; }
.arsh-menu .sub-menu a { display: flex; color: var(--arsh-ink); }
.arsh-menu .arsh-mega > .sub-menu { display: none; inline-size: min(52rem, 92vw); grid-template-columns: repeat(3, 1fr); gap: var(--arsh-space-2); }
.arsh-menu .arsh-mega:hover > .sub-menu, .arsh-menu .arsh-mega:focus-within > .sub-menu { display: grid; }
.arsh-cta { white-space: nowrap; }
.arsh-drawer-toggle { display: none; margin-inline-start: auto; min-inline-size: var(--arsh-target); min-block-size: var(--arsh-target); padding: 0; border: 1px solid var(--arsh-border); border-radius: var(--arsh-radius-sm); background: transparent; color: inherit; cursor: pointer; }
.arsh-burger, .arsh-burger::before, .arsh-burger::after { display: block; inline-size: 20px; block-size: 2px; background: currentcolor; border-radius: 2px; margin-inline: auto; }
.arsh-burger { position: relative; }
.arsh-burger::before, .arsh-burger::after { content: ""; position: absolute; inset-inline-start: 0; }
.arsh-burger::before { inset-block-start: -6px; }
.arsh-burger::after { inset-block-start: 6px; }

.arsh-header--centered .arsh-header__inner { justify-content: center; }
.arsh-header--centered .arsh-nav { margin-inline: 0; }
.arsh-header--minimal .arsh-cta { margin-inline-start: auto; }
.arsh-header--transparent { position: fixed; inset-inline: 0; background: transparent; border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; --ab-header-ink: var(--arsh-on-deep); }
.arsh-header--transparent.is-scrolled, .arsh-drawer-open .arsh-header--transparent { background: var(--arsh-surface); border-color: var(--arsh-line); --ab-header-ink: var(--arsh-ink); }

@media (max-width: 48em) {
  .arsh-header__inner { padding-block: var(--arsh-space-2); }
  .js .arsh-drawer-toggle { display: inline-flex; align-items: center; }
  .js .arsh-drawer { display: none; order: 3; inline-size: 100%; margin: 0; padding-block: var(--arsh-space-2) var(--arsh-space-4); color: var(--arsh-ink); }
  .js .arsh-drawer.is-open { display: block; }
  .js .arsh-header:has(.arsh-drawer.is-open) { background: var(--arsh-surface); }
  .arsh-menu { flex-direction: column; }
  .arsh-menu a { inline-size: 100%; }
  .arsh-menu .sub-menu { position: static; display: block; border: 0; box-shadow: none; padding-block: 0; padding-inline-start: var(--arsh-space-4); }
  .arsh-menu .arsh-mega > .sub-menu { display: block; inline-size: auto; }
  .arsh-cta { margin-inline-start: auto; }
}

/* ---------------------------------------------------------- content layouts */
.arsh-main--boxed, .arsh-main--wide { padding-block: var(--arsh-space-7); }
.arsh-main--full { padding: 0; }
.arsh-entry { margin: 0; }
.arsh-main--boxed .entry-content > *, .arsh-main--boxed .entry-header, .page-header { max-inline-size: var(--arsh-measure); margin-inline: auto; }
.arsh-main--boxed .entry-content > .alignwide { max-inline-size: var(--ab-wide); }
.arsh-main--full .entry-content > :where(:not(.alignfull):not(.alignwide):not([class*="arsh-"])) {
  max-inline-size: calc(var(--arsh-measure) + 2 * var(--arsh-space-4)); margin-inline: auto; padding-inline: var(--arsh-space-4);
}
.arsh-main--full .entry-content > * { margin-block: 0; }
.arsh-main--full .entry-content > :where(:not(.alignfull):not([class*="arsh-"])) { margin-block: var(--arsh-space-4); }
.alignfull { inline-size: 100vw; max-inline-size: 100vw; margin-inline: calc(50% - 50vw); }
.arsh-main--full .alignfull { margin-inline: 0; inline-size: 100%; max-inline-size: none; }
.alignwide { inline-size: min(100%, var(--ab-wide)); margin-inline: auto; }
.alignleft { float: inline-start; margin-inline-end: var(--arsh-space-4); }
.alignright { float: inline-end; margin-inline-start: var(--arsh-space-4); }
.aligncenter { display: block; margin-inline: auto; }
.entry-header { margin-block-end: var(--arsh-space-5); }
.entry-title a { color: var(--arsh-ink); text-decoration: none; }
.entry-title a:hover { color: var(--arsh-primary); }
.entry-meta { color: var(--arsh-muted); font-size: var(--arsh-text-sm); }
.entry-content > * + * { margin-block-start: var(--arsh-space-4); }
.entry-content blockquote { padding-inline-start: var(--arsh-space-4); border-inline-start: 4px solid var(--arsh-accent); color: var(--arsh-muted); }
.entry-content table { inline-size: 100%; border-collapse: collapse; }
.entry-content th, .entry-content td { padding: var(--arsh-space-2) var(--arsh-space-3); border: 1px solid var(--arsh-line); text-align: start; }
.entry-content pre { overflow-x: auto; padding: var(--arsh-space-4); background: var(--arsh-surface-2); border-radius: var(--arsh-radius-sm); direction: ltr; text-align: start; }
.arsh-hero-media { margin-block-end: var(--arsh-space-5); border-radius: var(--arsh-radius-lg); overflow: hidden; }
.arsh-hero-media img { display: block; inline-size: 100%; }
.wp-caption-text, figcaption { color: var(--arsh-muted); font-size: var(--arsh-text-sm); }

.arsh-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: var(--arsh-space-5); }
.arsh-card-post { display: flex; flex-direction: column; padding: var(--arsh-space-4); background: var(--arsh-surface-2); border: 1px solid var(--arsh-line); border-radius: var(--arsh-radius-lg); }
.arsh-card-post__media { display: block; margin: calc(-1 * var(--arsh-space-4)) calc(-1 * var(--arsh-space-4)) var(--arsh-space-3); overflow: hidden; border-start-start-radius: var(--arsh-radius-lg); border-start-end-radius: var(--arsh-radius-lg); }
.arsh-card-post__media img { display: block; inline-size: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.arsh-card-post .entry-title { font-size: var(--arsh-text-lg); margin-block-end: var(--arsh-space-1); }

/* --------------------------------------------------------------- controls */
.button, .wp-block-button__link, input[type="submit"], button[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; min-block-size: var(--arsh-target);
  padding-inline: var(--arsh-space-5); border: 0; border-radius: var(--arsh-radius-sm);
  background: var(--arsh-primary); color: var(--arsh-on-primary); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background-color var(--arsh-duration) var(--arsh-ease);
}
.button:hover, .wp-block-button__link:hover, input[type="submit"]:hover, button[type="submit"]:hover { background: var(--arsh-primary-hover); color: var(--arsh-on-primary); }
input[type="text"], input[type="email"], input[type="url"], input[type="search"], input[type="password"], textarea, select {
  inline-size: 100%; min-block-size: var(--arsh-target); padding: var(--arsh-space-2) var(--arsh-space-3);
  border: 1px solid var(--arsh-border); border-radius: var(--arsh-radius-sm); background: var(--arsh-surface); color: var(--arsh-ink); font: inherit;
}
label { display: inline-block; margin-block-end: var(--arsh-space-1); font-size: var(--arsh-text-sm); font-weight: 500; }
.search-form { display: flex; gap: var(--arsh-space-2); max-inline-size: var(--arsh-measure); }
.search-form label { flex: 1; margin: 0; }
.pagination, .post-navigation { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--arsh-space-3); max-inline-size: var(--arsh-measure); margin: var(--arsh-space-6) auto 0; }
.pagination .page-numbers { display: inline-flex; align-items: center; justify-content: center; min-inline-size: var(--arsh-target); min-block-size: var(--arsh-target); padding-inline: var(--arsh-space-2); border-radius: var(--arsh-radius-sm); text-decoration: none; }
.pagination .current { background: var(--arsh-primary); color: var(--arsh-on-primary); }
.comments-area { max-inline-size: var(--arsh-measure); margin: var(--arsh-space-7) auto 0; }
.comment-list { padding: 0; list-style: none; }
.comment-body { padding: var(--arsh-space-4); margin-block-end: var(--arsh-space-3); background: var(--arsh-surface-2); border-radius: var(--arsh-radius-md); }
.comment-meta { color: var(--arsh-muted); font-size: var(--arsh-text-sm); }

/* ------------------------------------------------------------------- 404 */
.arsh-404 { display: grid; justify-items: center; gap: var(--arsh-space-3); padding-block: var(--arsh-space-7); text-align: center; }
.arsh-404__code {
  margin: 0; font-size: clamp(5rem, 3rem + 12vw, 11rem); font-weight: 900; line-height: 1;
  background-image: linear-gradient(135deg, var(--arsh-primary), var(--arsh-accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.arsh-404__text { max-inline-size: var(--arsh-measure); color: var(--arsh-muted); }
.arsh-404 .search-form { inline-size: min(100%, 28rem); }

/* ---------------------------------------------------------------- footer */
.site-footer { background: var(--arsh-surface-2); border-block-start: 1px solid var(--arsh-line); color: var(--arsh-muted); font-size: var(--arsh-text-sm); }
.arsh-footer__inner { max-inline-size: var(--ab-wide); margin-inline: auto; padding: var(--arsh-space-6) var(--arsh-space-4); }
.arsh-footer__title { margin: 0 0 var(--arsh-space-2); color: var(--arsh-ink); font-weight: 800; font-size: var(--arsh-text-md); }
.arsh-footer__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--arsh-space-3); margin-block-end: var(--arsh-space-4); }
.arsh-footer__row .arsh-footer__title { margin: 0; }
.arsh-footer__cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: var(--arsh-space-6); margin-block-end: var(--arsh-space-5); }
.arsh-footer__menu { flex-direction: column; gap: 0; }
.arsh-footer__row .arsh-footer__menu { flex-direction: row; gap: var(--arsh-space-2); }
.arsh-footer__menu a { display: inline-flex; align-items: center; min-block-size: var(--arsh-target); color: var(--arsh-muted); }
.arsh-footer__menu a:hover { color: var(--arsh-primary); }
.arsh-footer__legal { margin: 0; padding-block-start: var(--arsh-space-3); border-block-start: 1px solid var(--arsh-line); }
.arsh-footer--minimal .arsh-footer__inner { text-align: center; padding-block: var(--arsh-space-5); }
.arsh-footer--minimal .arsh-footer__legal { border: 0; padding: 0; }

/* --------------------------------------------------------- motion + print */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .arsh-header, .arsh-header__inner, .arsh-menu a, .button { transition: none; }
}
@media print {
  .arsh-announce, .arsh-header, .site-footer, .skip-link, .search-form, .pagination, .post-navigation, .comments-area, .arsh-drawer-toggle { display: none; }
  body { background: Canvas; color: CanvasText; font-size: 12pt; line-height: 1.6; }
  .arsh-main--boxed, .arsh-main--wide { padding: 0; }
  .alignfull { inline-size: auto; max-inline-size: none; margin-inline: 0; }
  .entry-content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
  h1, h2, h3, img, figure, blockquote { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
}
