/* KaraHub — base reset, typography, utilities. Built on tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--kh-sand);
  color: var(--kh-graphite);
  font-family: var(--kh-la);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

html[lang="fa"] body,
html:lang(fa) body {
  font-family: var(--kh-fa);
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--kh-teal);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 0.6em;
  color: var(--kh-petrol);
}

p {
  margin: 0 0 1em;
  text-align: justify;
  text-align-last: start;
}

ul,
ol {
  margin: 0 0 1em;
  padding-inline-start: 1.4em;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--kh-teal);
  outline-offset: 2px;
  border-radius: var(--kh-r-sm);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Section-entry motion (brand book §12): fade + 16px move up, once, on
   scroll into view. Scoped under .kh-js (set by an inline script in
   <head>) so content stays visible if JavaScript never runs. */
.kh-js .kh-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s var(--kh-ease), transform 0.4s var(--kh-ease);
}

.kh-js .kh-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.kh-family-grid .kh-reveal:nth-child(2) { transition-delay: 0.08s; }
.kh-family-grid .kh-reveal:nth-child(3) { transition-delay: 0.16s; }
.kh-post-grid .kh-reveal:nth-child(2) { transition-delay: 0.08s; }
.kh-post-grid .kh-reveal:nth-child(3) { transition-delay: 0.16s; }

/* Utilities */

.kh-container {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.kh-container--narrow {
  max-width: 760px;
}

.kh-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.kh-skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -3rem;
  background: var(--kh-petrol);
  color: var(--kh-n0);
  padding: 0.6em 1em;
  border-radius: var(--kh-r-sm);
  z-index: 100;
  transition: top 0.2s var(--kh-ease);
}

.kh-skip-link:focus {
  top: 1rem;
}

.kh-prose h2,
.kh-prose h3,
.kh-prose h4 {
  margin-top: 1.4em;
}

.kh-prose img {
  border-radius: var(--kh-r-md);
  margin-block: 1em;
}

.kh-prose figure {
  margin: 1.5em 0;
}

.kh-prose figcaption {
  font-size: 0.85rem;
  color: var(--kh-n500);
  margin-top: 0.5em;
  text-align: center;
}

.kh-prose iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: none;
  border-radius: var(--kh-r-md);
  margin-block: 1.5em;
}

.kh-prose pre {
  background: var(--kh-graphite);
  color: var(--kh-sand);
  padding: 1em 1.25em;
  border-radius: var(--kh-r-md);
  overflow-x: auto;
  font-family: var(--kh-mono);
  font-size: 0.9rem;
  margin-block: 1.2em;
}

.kh-prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.kh-prose code {
  background: var(--kh-n200);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-family: var(--kh-mono);
  font-size: 0.9em;
}

.kh-prose a {
  text-decoration: underline;
}

.kh-prose blockquote {
  position: relative;
  margin: 1.75em 0;
  padding: 1.25em 1.5em;
  border-inline-start: 3px solid var(--kh-teal);
  border-radius: var(--kh-r-md);
  background: var(--kh-n50);
  color: var(--kh-petrol);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.6;
}

.kh-prose ol {
  list-style: none;
  padding-inline-start: 0;
  counter-reset: kh-ol;
  display: grid;
  gap: 0.85em;
}

.kh-prose ol > li {
  position: relative;
  counter-increment: kh-ol;
  padding-inline-start: 2.6em;
}

.kh-prose ol > li::before {
  content: counter(kh-ol);
  position: absolute;
  inset-inline-start: 0;
  top: 0.05em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  background: color-mix(in srgb, var(--kh-teal) 14%, transparent);
  color: var(--kh-petrol);
  font-weight: 700;
  font-size: 0.85em;
}

.kh-prose table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1em 0;
}

.kh-prose th,
.kh-prose td {
  border: 1px solid var(--kh-n200);
  padding: 0.5em 0.75em;
  text-align: start;
}

.kh-prose details {
  border: 1px solid var(--kh-n200);
  border-radius: var(--kh-r-md);
  padding: 0.9em 1.1em;
  margin-block: 0.75em;
  background: var(--kh-n0);
  transition: border-color 0.2s var(--kh-ease), box-shadow 0.2s var(--kh-ease);
}

.kh-prose details:hover {
  border-color: var(--kh-teal);
}

.kh-prose details[open] {
  box-shadow: var(--kh-sh-1);
}

.kh-prose details + details {
  margin-top: 0.6em;
}

.kh-prose summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  font-weight: 700;
  cursor: pointer;
  color: var(--kh-petrol);
  list-style: none;
}

.kh-prose summary::-webkit-details-marker {
  display: none;
}

.kh-prose summary::after {
  content: '';
  flex-shrink: 0;
  width: 0.8em;
  height: 0.8em;
  background-color: var(--kh-teal);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat center / contain;
  transition: transform 0.25s var(--kh-ease);
}

.kh-prose details[open] summary::after {
  transform: rotate(180deg);
}

.kh-prose details p {
  margin-top: 0.75em;
  margin-bottom: 0;
  color: var(--kh-n600);
}
