/* gulfcalc. Layout: one reading column (max 1120px); calculator pages split into form/result + side panel.
   Logical properties (inline/block) keep the layout correct in Arabic (RTL). */
:root {
  --bg: #f5f8f7;
  --surface: #ffffff;
  --ink: #10211d;
  --muted: #566862;
  --line: #dae3e0;
  --accent: #0b6e5f;
  --accent-strong: #08574b;
  --accent-soft: #e2f1ee;
  --accent-ink: #ffffff;
  --gold: #8f5a14;
  --gold-soft: #fbf1e2;
  --warn: #9a3412;
  --warn-soft: #fdeee6;
  --chrome: #e7ecea;
  --shadow: 0 12px 32px -20px rgba(8, 40, 34, 0.35);
  --display: 'Sora', 'Segoe UI', system-ui, sans-serif;
  --body: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --arabic: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0c1412;
    --surface: #131f1c;
    --ink: #e4edea;
    --muted: #93a6a0;
    --line: #243430;
    --accent: #3db39c;
    --accent-strong: #5cc8b2;
    --accent-soft: #16302a;
    --accent-ink: #04201a;
    --gold: #e2a84e;
    --gold-soft: #2b2416;
    --warn: #f0a07a;
    --warn-soft: #2e1b13;
    --chrome: #1a2723;
    --shadow: 0 12px 32px -20px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0c1412;
  --surface: #131f1c;
  --ink: #e4edea;
  --muted: #93a6a0;
  --line: #243430;
  --accent: #3db39c;
  --accent-strong: #5cc8b2;
  --accent-soft: #16302a;
  --accent-ink: #04201a;
  --gold: #e2a84e;
  --gold-soft: #2b2416;
  --warn: #f0a07a;
  --warn-soft: #2e1b13;
  --chrome: #1a2723;
  --shadow: 0 12px 32px -20px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
}
:lang(ar) body,
body:lang(ar) {
  font-family: var(--arabic);
}
[hidden] {
  display: none !important;
}
img {
  max-width: 100%;
}
a {
  color: var(--accent);
}
a:hover {
  color: var(--accent-strong);
}
h1,
h2,
h3 {
  font-family: var(--display);
  line-height: 1.25;
  text-wrap: balance;
  margin: 0;
}
:lang(ar) h1,
:lang(ar) h2,
:lang(ar) h3 {
  font-family: var(--arabic);
  font-weight: 700;
}
h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
}
h2 {
  font-size: 1.35rem;
  font-weight: 600;
}
h3 {
  font-size: 1.05rem;
  font-weight: 600;
}
p {
  margin: 0;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip {
  position: absolute;
  inset-inline-start: 8px;
  top: -48px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 12px;
  border-radius: 6px;
  z-index: 20;
}
.skip:focus {
  top: 8px;
}

.wrap {
  max-width: 1120px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-block: 12px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}
.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.top-nav a {
  color: var(--muted);
  text-decoration: none;
}
.top-nav a:hover {
  color: var(--ink);
}
.lang-switch {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 10px;
  color: var(--ink) !important;
}
.lang-switch:lang(ar) {
  font-family: var(--arabic);
}
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.theme-toggle span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--ink) 50%, transparent 50%);
  border: 2px solid var(--ink);
}

.main {
  padding-block: 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Home */
.hero {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-block: 16px 0;
}
.lede {
  color: var(--muted);
  max-width: 65ch;
  font-size: 1.05rem;
}
.search input {
  width: 100%;
  max-width: 560px;
}
.groups {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover {
  border-color: var(--accent);
  color: var(--ink);
  transform: translateY(-1px);
}
.card p {
  font-size: 0.9rem;
  color: var(--muted);
}
.why {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px 32px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}
.why div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.why p {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Calculator page */
.crumbs {
  font-size: 0.85rem;
  color: var(--muted);
}
.crumbs a {
  color: var(--muted);
}
.page-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
}
/* Form on the left, result on the right and kept in view while typing (desktop).
   On phones the result follows the form. */
.calc {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .calc {
    grid-template-columns: minmax(0, 1fr);
  }
}
.calc-form {
  min-width: 0;
}
.calc-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
@media (min-width: 901px) {
  .calc-result {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }
}
.calc-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}
#calc-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Optional sections of the form. */
.more {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.more > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}
.more > summary::-webkit-details-marker {
  display: none;
}
.more > summary::before {
  content: '+';
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--accent-soft);
  font-weight: 700;
}
.more[open] > summary::before {
  content: '−';
}
.more > .form {
  margin-top: 12px;
}

/* Quick-pick buttons under a number field. */
.picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pick {
  font: inherit;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.pick:hover {
  border-color: var(--accent);
}
.pick[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel-title {
  font-size: 1rem;
}
.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 560px) {
  .form {
    grid-template-columns: minmax(0, 1fr);
  }
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label {
  font-size: 0.9rem;
  font-weight: 500;
}
.hint {
  font-size: 0.8rem;
  color: var(--muted);
}
input,
select {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}
input[type='number'] {
  font-variant-numeric: tabular-nums;
}
input:hover,
select:hover {
  border-color: var(--muted);
}

.result {
  border-radius: 12px;
  background: var(--accent-soft);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.result.is-error {
  background: var(--warn-soft);
  color: var(--warn);
}
.result-label {
  font-size: 0.9rem;
  color: var(--muted);
}
.result-big {
  font-family: var(--display);
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
:lang(ar) .result-big {
  font-family: var(--arabic);
}
.result-big .cur {
  font-size: 0.45em;
  font-weight: 600;
  vertical-align: 0.35em;
}
.badge {
  align-self: flex-start;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-info {
  background: var(--gold-soft);
  color: var(--gold);
}
.rows {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
}
.rows div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 16px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}
.rows dt {
  color: var(--muted);
}
.rows dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: end;
}
.rows .strong dt,
.rows .strong dd {
  color: var(--ink);
  font-weight: 700;
}
.notes {
  margin: 0;
  padding-inline-start: 18px;
  font-size: 0.82rem;
  color: var(--muted);
}
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--line);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
th,
td {
  text-align: start;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
tr:last-child td {
  border-bottom: 0;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}
.btn:hover {
  border-color: var(--muted);
  color: var(--ink);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn.primary:hover {
  background: var(--accent-strong);
  color: var(--accent-ink);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.box h2 {
  font-size: 1rem;
}
.box ul {
  margin: 0;
  padding-inline-start: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.box ul.links {
  list-style: none;
  padding: 0;
}

.guide {
  max-width: 72ch;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.guide section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.guide p {
  color: var(--ink);
}
.guide > h2 {
  margin-top: 12px;
}
.faq {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.faq details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--surface);
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
}
.faq details p {
  margin-top: 8px;
  color: var(--muted);
}
.law,
.disclaimer {
  font-size: 0.88rem;
  color: var(--muted);
}
.disclaimer {
  border-inline-start: 3px solid var(--line);
  padding-inline-start: 12px;
}

.ad {
  min-height: 100px;
  margin-block: 8px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.foot {
  padding-block: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 0.9rem;
}
.foot-links a {
  color: var(--muted);
}
.foot-note {
  font-size: 0.8rem;
  color: var(--muted);
}
.foot-note a {
  color: var(--muted);
}

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

/* Print: keep the result and the inputs, drop navigation and ads. */
@media print {
  .site-header,
  .site-footer,
  .actions,
  .calc-info,
  .more:not([open]),
  .ad,
  .crumbs,
  .faq,
  .skip {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .panel,
  .result {
    box-shadow: none;
    border: 1px solid #999;
    background: #fff;
  }
  .calc {
    grid-template-columns: 1fr;
  }
}
