/*
 * Shell and layout: skip link, header, navigation, footer, containers and the
 * sidebar split. Colours come from tokens in app.css; this file must contain
 * no literals and no physical-direction properties (see css-hygiene.test.js).
 */

/* ---- Containers ---- */
.wrap {
  width: 100%;
  max-width: 88rem;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main.wrap {
  /* flex child of body, so the footer is pushed down on short pages */
  flex: 1 0 auto;
  padding-block: 1.25rem 2rem;
}

/*
 * Full-bleed band inside the centred container. Symmetric inline values keep
 * it correct under RTL, and html{overflow-x:clip}


/* ---- Skip link ---- */
/* Offscreen until focused. Kept as the first focusable element in the document
   so keyboard users reach the main landmark immediately. */
.skip {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  z-index: 100;
}

.skip:focus {
  inset-inline-start: 1rem;
  top: 1rem;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}

/* ---- Header ---- */
.site-header {
  background: var(--header-bg);
  border-block-end: 1px solid var(--header-input);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-block: 0.5rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  min-inline-size: 0;
  max-inline-size: 100%;
}

.brand > strong { min-inline-size: 0; white-space: normal; overflow-wrap: anywhere; }

.brand-mark {
  inline-size: 2.5rem;
  block-size: 2.5rem;
  flex: none;
}

.brand-wordmark {
  display: grid;
  line-height: 1.05;
  min-inline-size: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.brand-wordmark strong {
  font-size: var(--step-1);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-wordmark small {
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 700;
  margin-block-start: 0.18rem;
}

/* ---- Navigation ---- */
.nav {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  white-space: nowrap;
}

.nav a:hover { background: var(--bg2); }

.nav a.active {
  background: var(--bg2);
  color: var(--accent2);
  font-weight: 600;
}

/* ---- Sidebar split (account / admin shells) ---- */
.cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 880px) {
  .cols { grid-template-columns: 248px 1fr; }
  .side {
    position: sticky;
    top: 5.25rem;
    max-block-size: calc(100vh - 6.25rem);
    overflow-y: auto;
  }
}

.side {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem;
  align-self: start;
}

.side a {
  display: block;
  padding: 0.45rem 0.6rem;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.side a:hover {
  background: var(--bg2);
  color: var(--accent);
}

.side a.active {
  background: var(--bg2);
  color: var(--accent);
  border-inline-start: 3px solid var(--accent);
  font-weight: 700;
}

.side-group {
  margin-block-start: 0.6rem;
  padding-block-start: 0.6rem;
  border-block-start: 1px solid var(--line);
}

.side-group:first-child {
  margin-block-start: 0;
  padding-block-start: 0;
  border-block-start: 0;
}

.side-title {
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  font-weight: 700;
}

.col-main { min-inline-size: 0; }

/* ---- Footer ---- */
.site-footer {
  background: var(--header-bg);
  color: var(--header-muted);
  font-size: var(--step--1);
  margin-block-start: auto;
}

.site-footer a { color: var(--header-muted); text-decoration: none; }
.site-footer a:hover { color: var(--header-ink); text-decoration: underline; }

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem 2rem;
  align-items: start;
  padding-block: 2rem 1rem;
}

.footer-brand {
  display: grid;
  gap: 0.75rem;
  min-inline-size: 0;
}
.footer-brand-link { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.7rem; min-block-size: 44px; max-inline-size: 100%; justify-self: start; }
.footer-brand p { margin: 0; max-inline-size: 30ch; line-height: 1.7; }

.footer-brand img {
  inline-size: 2.15rem;
  block-size: 2.15rem;
  flex: none;
}

.footer-brand strong { color: var(--header-ink); font-size: var(--step-1); min-inline-size: 0; overflow-wrap: anywhere; }
.footer-social { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.footer-social-link { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 0.75rem; min-block-size: 44px; max-inline-size: 100%; border-radius: var(--radius-sm); background: var(--header-input); color: var(--header-ink); }
.footer-links { display: grid; align-content: start; min-inline-size: 0; }
.footer-links h2 { font-size: var(--step--1); color: var(--header-ink); margin-block: 0 0.4rem; }
.footer-links a { display: flex; align-items: center; min-block-size: 44px; line-height: 1.5; overflow-wrap: anywhere; }
.footer-meta { line-height: 1.7; grid-column: 1 / -1; border-block-start: 1px solid var(--header-input); padding-block-start: 1rem; }

@media (min-width: 640px) {
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
  .footer-grid { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
}

.nav-group { display: flex; align-items: center; flex-wrap: wrap; }
.nav-submenu { position: relative; font-size: var(--step--1); }
.nav-submenu summary { padding: 0.5rem; cursor: pointer; }
.nav-submenu > div { display: grid; padding: 0.5rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.frontend-shell {
  color-scheme: light;
  --font-sans: "Manrope", "Noto Sans Arabic", system-ui, sans-serif;
  --control-border: var(--storefront-control-border);
  --header-bg: var(--storefront-header-bg);
  --header-input: var(--storefront-header-input);
  --header-ink: var(--storefront-header-ink);
  --header-muted: var(--storefront-header-muted);
  --shadow-focus: var(--storefront-focus-shadow);
  --focus-ring: var(--storefront-focus-shadow);
  --btn-primary-shadow: var(--storefront-action-shadow);
  --btn-primary-hover-shadow: var(--storefront-action-shadow);
  --shadow-hover: var(--storefront-card-shadow);
}
.frontend-shell main { min-inline-size: 0; overflow-wrap: anywhere; }
.frontend-shell input:not([type="hidden"]), .frontend-shell select, .frontend-shell textarea { font-size: 1rem; max-inline-size: 100%; border-color: var(--control-border); }
.frontend-shell .btn, .frontend-shell summary, .frontend-shell .nav a { min-block-size: 44px; }

/* One registry, one responsive navigation disclosure; no duplicate header links. */
.site-header .brand { color: var(--header-ink); }
.site-header .brand-wordmark small { color: var(--header-muted); }
.header-actions { display: flex; gap: 0.75rem; flex: 0 0 auto; align-items: center; max-inline-size: 100%; }
.header-disclosure { position: relative; }
.header-disclosure > summary { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border: 0; border-radius: var(--radius-sm); color: var(--header-ink); font-size: var(--step--1); list-style: none; cursor: pointer; }
.header-disclosure > summary:hover { background: var(--header-input); }
.header-disclosure > summary::after { content: '⌄'; }
.header-disclosure > summary::-webkit-details-marker { display: none; }
.account-menu > summary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease; }
.account-menu > summary:hover, .account-menu > summary:focus-visible, .account-menu[open] > summary { background: var(--accent2); border-color: var(--accent2); color: var(--on-accent); }
.account-menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.header-dropdown, .site-header .nav-submenu > div { position: absolute; inset-block-start: calc(100% + 0.25rem); inset-inline-start: 0; display: grid; inline-size: 16rem; max-inline-size: calc(100vw - 2rem); max-block-size: 60vh; overflow-y: auto; padding: 0.4rem; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 30; }
.header-actions .header-dropdown { inset-inline-start: auto; inset-inline-end: 0; }
.header-dropdown a, .header-dropdown span, .header-dropdown strong { padding: 0.5rem 0.65rem; color: var(--ink); text-decoration: none; font-size: var(--step--1); }
.header-dropdown a { min-block-size: 44px; display: flex; align-items: center; }
.header-dropdown a:hover { background: var(--bg2); }
.header-dropdown strong { color: var(--muted); }
.header-dropdown .linklike { inline-size: 100%; text-align: start; padding: 0.6rem; min-block-size: 44px; }
.header-search { flex: 0 1 32rem; inline-size: 100%; max-inline-size: 34rem; display: flex; align-items: center; min-inline-size: 0; gap: 0.35rem; margin-inline: auto; background: var(--header-input); border-radius: var(--radius-pill, 9999px); padding-inline: 0.75rem 0.35rem; border: 1px solid var(--control-border); transition: border-color 0.18s ease, box-shadow 0.18s ease; }
.header-search:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.header-search-icon { display: flex; align-items: center; color: var(--header-muted); flex: none; }
.header-search input { min-inline-size: 0; inline-size: 100%; min-block-size: 40px; background: transparent; color: var(--header-ink); border: 0; border-radius: 0; padding: 0.4rem 0.25rem; font-size: var(--step--1); outline: none; }
.header-search input::placeholder { color: var(--header-muted); }
.header-search button, .header-search-btn { background: var(--accent); color: var(--on-accent); border: 0; border-radius: var(--radius-pill, 9999px); padding: 0.35rem 0.85rem; min-block-size: 32px; font-size: var(--step--1); font-weight: 600; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; transition: background-color 0.18s ease; flex: none; }
.header-search button:hover, .header-search-btn:hover { background: var(--accent2); }
.site-subnav { background: var(--header-bg); border-block-start: 1px solid var(--header-input); }
.subnav-bar { display: flex; align-items: center; padding-block: 0.2rem; min-inline-size: 0; }
.subnav-bar .storefront-menu { inline-size: 100%; }
@media (max-width: 820px) {
  .site-header .bar { gap: 0.75rem; }
  .site-header .brand-mark { inline-size: 2rem; block-size: 2rem; }
  .site-header .brand-wordmark strong { font-size: var(--step-0); }
  .header-actions { margin-inline-start: auto; gap: 0.5rem; flex-wrap: wrap; }
  .header-search { order: 3; flex: 1 1 100%; margin-inline: 0; min-inline-size: 0; max-inline-size: 100%; }
  .header-disclosure > summary { padding-inline: 0.4rem; }
}

@media (max-width: 879px) {
  .side {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.6rem;
  }
  .side-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-block-start: 0;
    padding-block-start: 0;
    border-block-start: 0;
    inline-size: 100%;
  }
  .side-title {
    inline-size: 100%;
    padding-block: 0.2rem;
  }
}

.storefront-menu { min-inline-size: 0; }
.storefront-menu > summary { font-size: var(--step--1); cursor: pointer; padding: 0.5rem; min-block-size: 44px; display: flex; align-items: center; border-radius: var(--radius-sm); }
.storefront-menu > .nav { gap: 0.25rem; }
@media (min-width: 1100px) {
  .storefront-menu > summary { display: none; }
}
@media (max-width: 1099px) {
  .storefront-menu[open] { flex-basis: 100%; order: 3; }
  .storefront-menu > .nav { align-items: stretch; flex-direction: column; padding-block: 0.5rem; }
  .storefront-menu .nav-group { display: block; }
  .storefront-menu .nav a { display: flex; min-block-size: 44px; white-space: normal; overflow-wrap: anywhere; }
  .storefront-menu .nav-submenu summary { white-space: normal; overflow-wrap: anywhere; }
  .storefront-menu .nav-submenu > div { position: static; inline-size: auto; max-inline-size: none; box-shadow: none; }
  .site-header .bar { gap: 0.5rem; }
}

.header-account-label { min-inline-size: 0; }
.header-actions .header-disclosure > summary { min-inline-size: 44px; justify-content: center; }
@media (max-width: 420px) {
  .site-header .brand-wordmark small { display: none; }
}

/* The tiny same-origin head bootstrap prevents a collapsed-menu layout shift;
   without scripts or when enhancement fails, navigation stays native and open. */
@media (max-width: 1099px) {
  .frontend-js .storefront-menu[open]:not([data-navigation-ready]) { flex-basis: auto; order: 0; }
  .frontend-js .storefront-menu:not([data-navigation-ready]) > .nav { display: none; }
}

/* Approved Software studio shell. Shared page owners retain their native actions. */
html[lang="ar"] .frontend-shell { --font-sans: "Noto Sans Arabic", "Manrope", system-ui, sans-serif; }
.frontend-shell .bar { padding-block: 0.65rem; }
.frontend-shell .brand-wordmark strong { letter-spacing: -0.04em; font-size: 1.3rem; }
.locale-switch { display: inline-flex; align-items: center; justify-content: center; min-block-size: 44px; padding-inline: 0.25rem; font-size: 0.85rem; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.page-guide { display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1.5rem; padding: 0.9rem 1rem; margin-block-end: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); }
.page-guide > p { margin: 0; flex: 1 1 24rem; color: var(--muted); font-size: var(--step--1); }
.page-guide details { min-inline-size: 0; flex: 0 1 12rem; max-inline-size: 100%; }
.page-guide summary { color: var(--accent); min-block-size: 44px; display: flex; align-items: center; font-size: var(--step--1); font-weight: 700; }
.page-guide ol { padding-inline-start: 1.25rem; max-inline-size: 38rem; font-size: var(--step--1); color: var(--muted); }
.account-navigation { inline-size: 100%; }
.account-navigation > summary { padding: 0.65rem; font-weight: 700; min-block-size: 44px; color: var(--ink); }
.account-workspace .side { display: block; padding: 0.65rem; }
.account-workspace .side a { min-block-size: 44px; display: flex; align-items: center; font-size: var(--step--1); }
.account-workspace .side a[aria-current="page"] { background: var(--bg2); color: var(--accent); font-weight: 700; }
.frontend-shell .col-main > .card { margin-block: 1rem; }
.frontend-shell .auth-card { padding: clamp(1.2rem, 4vw, 2rem); border-radius: var(--radius-lg); box-shadow: var(--storefront-card-shadow); }
.frontend-shell .auth-header { text-align: start; }
.frontend-shell .auth-icon { margin-inline: 0; }
@media (min-width: 880px) {
  .account-navigation > summary { display: none; }
}
@media (max-width: 879px) {
  .frontend-js .account-navigation:not([data-navigation-ready]) > .side-group { display: none; }
}
@media (max-width: 420px) {
  .frontend-shell .bar { gap: 0.35rem; padding-inline: 0.8rem; }
  .frontend-shell .brand-wordmark strong { font-size: 1.05rem; }
  .frontend-shell .brand { gap: 0.35rem; }
  .frontend-shell .brand-mark { inline-size: 1.8rem; block-size: 1.8rem; }
  .locale-switch { font-size: 0.75rem; }
  .header-actions { gap: 0.2rem; }
  .header-actions .header-disclosure > summary { gap: 0.2rem; font-size: 0.75rem; padding-inline: 0.25rem; }
  .mobile-menu-label { display: none; }
  .storefront-menu > summary { min-inline-size: 36px; justify-content: center; padding-inline: 0.25rem; }
}
