/* assets/css/base.css */
/* Design Language v1 – calc.tartarani.ir */
/* Scope: tokens, reset, base typography */
/* =================================
   Font Face – Yekan Bakh FaNum
   Brand font (locked) 
   =================================================================================== */

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Thin.woff2?v=20260221a') format('woff2');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Light.woff2?v=20260221a') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Regular.woff2?v=20260221a') format('woff2'),
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Regular.woff?v=20260221a') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Regular.woff2?v=20260221a') format('woff2'),
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Regular.woff?v=20260221a') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-SemiBold.woff2?v=20260221a') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Bold.woff2?v=20260221a') format('woff2'),
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Bold.woff?v=20260221a') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-ExtraBold.woff2?v=20260221a') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-Black.woff2?v=20260221a') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakh';
  src:
    url('/assets/fonts/yekan-bakh/YekanBakhFaNum-ExtraBlack.woff2?v=20260221a') format('woff2');
  font-weight: 950;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'YekanBakhFallback';
  src: local('Tahoma'), local('Segoe UI');
  font-style: normal;
  font-weight: 100 500;
  size-adjust: 98%;
  ascent-override: 92%;
  descent-override: 24%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'YekanBakhFallback';
  src: local('Tahoma Bold'), local('Segoe UI Bold'), local('Tahoma'), local('Segoe UI');
  font-style: normal;
  font-weight: 600 950;
  size-adjust: 98%;
  ascent-override: 92%;
  descent-override: 24%;
  line-gap-override: 0%;
}


/* Tokens are defined in /assets/css/tokens.css and loaded globally via partials/header.php */

/* =================================
   Minimal reset (sane, not aggressive)
   ================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}
html, body {
  height: 100%;
}
body {
  margin: 0;
  padding: 0;

  background: var(--bg-main);
  color: var(--text-main);

  font-family: 'YekanBakh', 'YekanBakhFallback', Tahoma, "Segoe UI", system-ui,
             -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;

  font-size: var(--fs-2);
  line-height: 1.6;
  font-synthesis: none;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

html.karmet-splash-boot,
body.karmet-splash-boot {
  background: var(--color-brand-500, #e5aa17);
  overflow: hidden;
}

/* =================================
   Base elements
   ================================= */
a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}
img, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

:focus {
  outline: none;
}

:focus-visible {
  box-shadow: var(--focus-ring);
  border-radius: 10px;
}

button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
/* =================================
   Utility text styles
   ================================= */
.muted {
  color: var(--text-muted);
}

.err {
  color: var(--danger);
}

/* iOS (Safari/PWA): فیلد با فونت کمتر از 16px هنگام فوکوس صفحه را زوم می‌کند و زوم برنمی‌گردد.
   شبکهٔ اطمینان کنار viewport (maximum-scale=1 در صفحه‌های اپ)؛ فقط iOS (touch-callout)، فقط ورودی‌های متنی. */
@supports (-webkit-touch-callout: none) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="button"]):not([type="submit"]):not([type="reset"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* =================================
   pwa-professional-v2 فاز ۴: حس اپ در حالت standalone (نصب‌شده)
   فقط وقتی کلاس is-standalone هست (partial pwa-head)؛ مرورگر معمولی دست‌نخورده می‌ماند.
   متن محتوا و ورودی‌ها عمداً انتخاب‌پذیر می‌مانند (کپی قیمت/نام + خطای iOS روی input با user-select:none).
   ================================= */
html.is-standalone,
html.is-standalone body {
  overscroll-behavior-y: none;
}
html.is-standalone #app-content {
  overscroll-behavior-y: contain;
}
html.is-standalone .app-head,
html.is-standalone .calc-bottom-nav,
html.is-standalone button,
html.is-standalone .btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
html.is-standalone a,
html.is-standalone img {
  -webkit-touch-callout: none;
}

/* =================================
   بازخورد فوری لمس: فشرده‌شدن دکمه‌ها + حالت «در حال انجام» (karmetSetPending در pwa_client.js)
   ================================= */
html.has-app-shell .btn:active,
html.has-app-shell button:active {
  transform: scale(0.97);
  filter: brightness(0.96);
}

.is-pending {
  position: relative;
  pointer-events: none;
  opacity: 0.78;
}
.is-pending::after {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-inline-start: 8px;
  vertical-align: -2px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  animation: karmetPendingSpin 0.7s linear infinite;
}
@keyframes karmetPendingSpin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .is-pending::after { animation: none; }
}

/* =================================
   کیبورد (pwa-professional-v2 فاز ۱۳ج): لینک «پرش به محتوا» + حلقهٔ فوکوس سراسری با اولویت کم (کامپوننت‌ها override می‌کنند)
   ================================= */
.skip-link {
  position: fixed;
  top: -64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2147483000;
  padding: 10px 18px;
  border-radius: 12px;
  background: #2a2621;
  color: #fffdf8;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
  transition: top 0.15s ease;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 12px;
  outline: 2px solid var(--accent, #e0a200);
  outline-offset: 2px;
}
#app-content:focus {
  outline: none;
}
:where(a, button, [role="button"], [tabindex]:not([tabindex="-1"]), input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--accent, #e0a200);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .skip-link { transition: none; }
}

/* =================================
   نوار اسکرول کارمت (pwa-professional-v2 فاز ۱۵) — فقط ماوس/دسکتاپ؛ لمسی دست‌نخورده
   باریک (۶px)، کمرنگ، گرد، با auto-hide: فقط هنگام اسکرول (is-scrolling) یا نزدیک لبه (is-sb-near) دیده می‌شود
   (scrollbar_autohide.js). Chrome/Edge/Safari: ::-webkit-scrollbar (دقیقاً ۶px با border شفاف)؛ Firefox: scrollbar-width/color.
   ================================= */
:root {
  --sb-thumb: rgba(42, 38, 33, 0.24);
  --sb-thumb-hover: rgba(42, 38, 33, 0.44);
  --sb-thumb-active: rgba(224, 162, 0, 0.6);
}
@media (hover: hover) and (pointer: fine) {
  /* Chrome / Edge / Safari */
  *::-webkit-scrollbar {
    width: 10px;
    height: 10px;
    background: transparent;
  }
  *::-webkit-scrollbar-track,
  *::-webkit-scrollbar-corner {
    background: transparent;
  }
  *::-webkit-scrollbar-thumb {
    background-color: transparent;
    border: 2px solid transparent;        /* thumb واقعی ۶px (۱۰ − ۲×۲) */
    background-clip: padding-box;
    border-radius: 999px;
    min-height: 40px;
    transition: background-color 0.18s ease;
  }
  .is-scrolling::-webkit-scrollbar-thumb,
  .is-sb-near::-webkit-scrollbar-thumb {
    background-color: var(--sb-thumb);
  }
  *::-webkit-scrollbar-thumb:hover {
    background-color: var(--sb-thumb-hover);
    border-width: 1px;                    /* روی hover کمی ضخیم‌تر (۸px) */
  }
  *::-webkit-scrollbar-thumb:active {
    background-color: var(--sb-thumb-active);
    border-width: 1px;
  }
  /* Firefox */
  @supports (-moz-appearance: none) {
    * {
      scrollbar-width: thin;
      scrollbar-color: transparent transparent;
    }
    .is-scrolling,
    .is-sb-near {
      scrollbar-color: var(--sb-thumb) transparent;
    }
  }
}
