/* سعرات السعودية / SaudiCalories. Single stylesheet, logical properties, RTL + LTR share this file. */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --ink: #16181d;
  --muted: #6b6f76;
  --accent: #d9480f;
  --accent-soft: #fdf0e7;
  --high: #c92a2a;
  --low: #2f9e44;
  --hairline: rgba(22, 24, 29, 0.12);
  --bg-dark: #16181d;
  --ink-inverse: #f7f6f3;

  --font-ar: "Tajawal", system-ui, sans-serif;
  --font-en: "DM Sans", system-ui, sans-serif;

  --max-cal: 2592;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ar);
  line-height: 1.6;
}

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

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

a {
  color: inherit;
}

.ltr {
  font-family: var(--font-en);
  letter-spacing: -0.01em;
  unicode-bidi: isolate;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.container {
  max-width: 760px;
  margin-inline: auto;
  padding-inline: 1.25rem;
}

/* ---------- Masthead ---------- */

.masthead {
  border-block-end: 1px solid var(--hairline);
  padding-block: 0.85rem;
}

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.masthead__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
}

.masthead__logo-wrap {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
}

.masthead__logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.65);
}

.masthead__word {
  font-family: var(--font-ar);
  font-weight: 900;
  font-size: 1.05rem;
}

html[lang="en"] .masthead__word {
  font-family: var(--font-en);
  font-weight: 800;
}

.masthead__links {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.masthead__links a {
  text-decoration: none;
  border-block-end: 1px solid transparent;
}

.masthead__links a:hover {
  border-block-end-color: var(--muted);
}

/* ---------- Hero ---------- */

.hero {
  padding-block: 2rem 1.25rem;
}

.hero h1 {
  font-family: var(--font-ar);
  font-weight: 900;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  margin: 0 0 0.6rem;
  line-height: 1.25;
}

html[lang="en"] .hero h1 {
  font-family: var(--font-en);
  font-weight: 800;
}

.hero__dek {
  font-family: var(--font-ar);
  font-weight: 500;
  color: var(--muted);
  max-width: 60ch;
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

html[lang="en"] .hero__dek {
  font-family: var(--font-en);
  font-weight: 500;
}

.hero__stats {
  font-family: var(--font-en);
  font-size: 15px;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

/* ---------- Filter chips + sort ---------- */

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-block: 1.25rem 0.75rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  font-family: var(--font-ar);
  font-size: 0.85rem;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

html[lang="en"] .chip {
  font-family: var(--font-en);
}

.chip.is-active {
  color: var(--ink);
  border-color: var(--ink);
  font-weight: 700;
}

.sort {
  display: flex;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.sort button {
  font-family: var(--font-ar);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

html[lang="en"] .sort button {
  font-family: var(--font-en);
}

.sort button.is-active {
  color: var(--ink);
  border-color: var(--ink);
  font-weight: 700;
}

/* ---------- Ledger ---------- */

.ledger {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  border-block-start: 1px solid var(--hairline);
}

.ledger__row {
  display: grid;
  /* The bar track must be an identical width on every row, otherwise bar lengths are not
     comparable between rows and the magnitude reading is meaningless. Names take the slack. */
  grid-template-columns: 28px 1fr clamp(140px, 26vw, 320px) auto;
  align-items: center;
  gap: 0.9rem;
  padding-block: 0.75rem;
  border-block-end: 1px solid var(--hairline);
}

.ledger__row[hidden] {
  display: none;
}

.ledger__logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  filter: saturate(0.65);
}

.ledger__names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ledger__name-ar {
  font-family: var(--font-ar);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[lang="en"] .ledger__name-ar {
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 1rem;
}

.ledger__name-en {
  font-family: var(--font-en);
  font-weight: 500;
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[lang="en"] .ledger__name-en {
  font-family: var(--font-ar);
  font-size: 0.8rem;
}

.ledger__bar {
  position: relative;
  height: 10px;
  /* Faint track, so the fill reads against it. Track and fill must never be the same colour. */
  background: rgba(22, 24, 29, 0.05);
  border-radius: 2px;
  overflow: hidden;
}

.ledger__bar span {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  background: rgba(217, 72, 15, 0.18);
  border-inline-end: 2px solid var(--accent);
  transition: width 150ms ease;
}

.ledger__cal {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1;
  min-width: 64px;
}

.ledger__cal .ltr {
  font-weight: 800;
  font-size: 1.9rem;
  color: var(--accent);
}

.ledger__kcal {
  font-family: var(--font-en);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-block-start: 0.15rem;
}

@media (max-width: 560px) {
  .ledger__row {
    grid-template-columns: 24px 1fr auto;
    grid-template-areas:
      "logo names cal"
      "bar bar bar";
    row-gap: 0.4rem;
  }
  .ledger__logo { grid-area: logo; width: 24px; height: 24px; }
  .ledger__names { grid-area: names; }
  .ledger__cal { grid-area: cal; }
  .ledger__bar { grid-area: bar; }
  .ledger__cal .ltr { font-size: 1.6rem; }
}

/* ---------- Attribution line ---------- */

.attribution {
  border-block-start: 1px solid var(--hairline);
  padding-block: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-block-end: 0;
}

.attribution a {
  color: var(--muted);
  text-decoration: underline;
}

/* ---------- Comparison (dark) ---------- */

.compare {
  background: var(--bg-dark);
  color: var(--ink-inverse);
  padding-block: 2.5rem;
  margin-block-start: 2rem;
}

.compare h2 {
  font-family: var(--font-ar);
  font-weight: 900;
  font-size: 1.6rem;
  margin: 0 0 1.25rem;
}

html[lang="en"] .compare h2 {
  font-family: var(--font-en);
  font-weight: 800;
}

.compare__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 560px) {
  .compare__grid {
    grid-template-columns: 1fr;
  }
}

.compare__card {
  background: rgba(247, 246, 243, 0.04);
  border: 1px solid rgba(247, 246, 243, 0.14);
  border-radius: 12px;
  padding: 1.25rem;
}

.compare__tag {
  display: inline-block;
  font-family: var(--font-en);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-block-end: 0.75rem;
}

.compare__tag--high {
  color: var(--high);
  border: 1px solid var(--high);
}

.compare__tag--low {
  color: var(--low);
  border: 1px solid var(--low);
}

.compare__name {
  font-family: var(--font-ar);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 0.15rem;
}

html[lang="en"] .compare__name {
  font-family: var(--font-en);
}

.compare__brand {
  font-family: var(--font-en);
  font-size: 0.8rem;
  color: rgba(247, 246, 243, 0.6);
  margin: 0 0 0.75rem;
}

.compare__cal {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 2.5rem;
  color: var(--accent);
}

.compare__kcal {
  font-family: var(--font-en);
  font-size: 0.75rem;
  color: rgba(247, 246, 243, 0.6);
  margin-inline-start: 0.35rem;
}

.compare__diff {
  margin-block-start: 1.25rem;
  font-family: var(--font-en);
  font-size: 0.95rem;
  color: rgba(247, 246, 243, 0.75);
}

.compare__diff .ltr {
  color: var(--ink-inverse);
  font-weight: 700;
}

/* ---------- FAQ ---------- */

.faq {
  padding-block: 2.5rem;
}

.faq h2 {
  font-family: var(--font-ar);
  font-weight: 900;
  font-size: 1.6rem;
  margin: 0 0 1.25rem;
}

html[lang="en"] .faq h2 {
  font-family: var(--font-en);
  font-weight: 800;
}

.faq__item {
  border-block-end: 1px solid var(--hairline);
  padding-block: 1.1rem;
}

.faq__item h3 {
  font-family: var(--font-ar);
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

html[lang="en"] .faq__item h3 {
  font-family: var(--font-en);
}

.faq__item p {
  margin: 0;
  color: var(--ink);
}

.faq__item a {
  text-decoration: underline;
}

/* ---------- Footer ---------- */

.site-footer {
  border-block-start: 1px solid var(--hairline);
  padding-block: 1.5rem 2.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: center;
  margin-block-end: 0.75rem;
}

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

/* ---------- Blog index ---------- */

.blog-list {
  list-style: none;
  margin: 1.5rem 0;
  padding: 0;
  border-block-start: 1px solid var(--hairline);
}

.blog-list li {
  border-block-end: 1px solid var(--hairline);
  padding-block: 1.25rem;
}

.blog-list h2 {
  font-family: var(--font-ar);
  font-weight: 700;
  font-size: 1.15rem;
  margin: 0 0 0.35rem;
}

.blog-list h2 a {
  text-decoration: none;
}

.blog-list h2 a:hover {
  text-decoration: underline;
}

.blog-list p {
  margin: 0 0 0.35rem;
  color: var(--muted);
}

.blog-list time {
  font-family: var(--font-en);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------- Article ---------- */

.article {
  padding-block: 1.5rem 3rem;
}

.article__breadcrumb {
  font-size: 0.8rem;
  color: var(--muted);
  margin-block-end: 1rem;
}

.article__breadcrumb a {
  text-decoration: underline;
}

.article h1 {
  font-family: var(--font-ar);
  font-weight: 900;
  font-size: clamp(1.5rem, 4.5vw, 2.1rem);
  line-height: 1.3;
  margin: 0 0 0.5rem;
}

.article__meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 1.5rem;
}

.article p {
  margin: 0 0 1.1rem;
  font-size: 1.02rem;
}

.article h2 {
  font-family: var(--font-ar);
  font-weight: 900;
  font-size: 1.35rem;
  margin: 2rem 0 0.85rem;
}

.article h3 {
  font-family: var(--font-ar);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 1.5rem 0 0.6rem;
}

.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.95rem;
}

.article caption {
  text-align: start;
  color: var(--muted);
  font-size: 0.8rem;
  margin-block-end: 0.5rem;
}

.article th,
.article td {
  border-block-end: 1px solid var(--hairline);
  padding: 0.55rem 0.5rem;
  text-align: start;
}

.article th {
  font-family: var(--font-ar);
  font-weight: 700;
  color: var(--muted);
  font-size: 0.85rem;
}

.article td .ltr,
.article th .ltr {
  font-weight: 700;
}

.article__source {
  border-block-start: 1px solid var(--hairline);
  margin-block-start: 2rem;
  padding-block-start: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.article__source a {
  text-decoration: underline;
}

/* ---------- 404 ---------- */

.notfound {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg-dark);
  color: var(--ink-inverse);
  text-align: center;
  font-family: var(--font-ar);
  font-size: 1.3rem;
}

.notfound a {
  color: var(--accent);
  font-size: 1rem;
  text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
