/* DataDev Pipe Weight Calculator — neumorphism.
   One soft surface lit from the top-left: controls and panels are raised out of it, data sits in pressed wells.
   Accent is sapphire blue (after the Tarnoor v3 system, red swapped for blue). */

@font-face { font-family: Estedad; src: url(../assets/fonts/estedad.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: Inter; src: url(../assets/fonts/inter.woff2) format("woff2"); font-weight: 100 900; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+011E-011F, U+0130, U+015E-015F, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212; }
@font-face { font-family: "IBM Plex Mono"; src: url(../assets/fonts/plexmono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(../assets/fonts/plexmono-500.woff2) format("woff2"); font-weight: 500 700; font-display: swap; }

:root {
  /* Native shells may report insets through CSS variables instead of env(). */
  --safe-t: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --bg: #ECF0F6; --hl: #FFFFFF; --sh: rgba(150, 165, 192, .45);
  --ink: #1B2433; --ink-2: #4A546C; --ink-3: #5F6980;
  --blue: #1F5FC8; --blue-deep: #0F3F94; --blue-glow: rgba(31, 95, 200, .30); --blue-tint: #E1EAF8;
  --danger: #C2303C;
  --f-text: Inter, Estedad, system-ui, sans-serif;
  --f-display: Inter, Estedad, system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", Estedad, ui-monospace, Menlo, Consolas, monospace;
  --raise: 9px 9px 20px var(--sh), -9px -9px 20px var(--hl);
  --raise-sm: 5px 5px 11px var(--sh), -5px -5px 11px var(--hl);
  --raise-xs: 3px 3px 7px var(--sh), -3px -3px 7px var(--hl);
  --press: inset 6px 6px 12px var(--sh), inset -6px -6px 12px var(--hl);
  --press-sm: inset 3px 3px 7px var(--sh), inset -3px -3px 7px var(--hl);
  --r-lg: 28px;
  color-scheme: light;
}
html[lang="fa"], html[lang="ar"] { --f-text: Estedad, Inter, Tahoma, sans-serif; --f-display: Estedad, Inter, Tahoma, sans-serif; }

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  min-height: 100dvh; background: var(--bg); color: var(--ink); font-family: var(--f-text); font-size: 15px; line-height: 1.7;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; touch-action: manipulation; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; }
::selection { background: var(--blue-tint); color: var(--blue-deep); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 12px; }

.app { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-t) + 14px) 16px calc(var(--safe-b) + 112px); }

/* .glass is the raised surface every panel in the markup uses. */
.glass { background: var(--bg); box-shadow: var(--raise); }

/* Header — a raised pill bar */
.top {
  position: sticky; top: calc(var(--safe-t) + 8px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px; padding-inline-start: 10px; border-radius: 999px; background: var(--bg); box-shadow: var(--raise);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo { width: 44px; height: 44px; border-radius: 50%; padding: 5px; background: var(--bg); box-shadow: var(--raise-sm); flex: none; object-fit: contain; }
.brand > div { min-width: 0; }
.brand h1 { font-weight: 800; font-size: clamp(15px, 4.2vw, 18px); line-height: 1.25; overflow-wrap: anywhere; }
.brand-sub { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); direction: ltr; text-align: start; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[dir="rtl"] .brand-sub { text-align: right; }
.dd { font-weight: 500; color: var(--ink-2); }
.dd span { color: var(--blue); }
.lang { position: relative; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px; border-radius: 999px; flex: none; color: var(--ink-2); }
.lang.glass { box-shadow: var(--press-sm); }
.lang svg { width: 17px; height: 17px; flex: none; }
.lang select { appearance: none; background: transparent; border: 0; font-weight: 600; font-size: 13px; outline: none; cursor: pointer; color: var(--ink); }

/* Hero */
.hero { margin-top: 22px; border-radius: 36px; padding: 24px 22px; position: relative; overflow: hidden; min-height: 176px; }
.hero h2 { font-weight: 800; font-size: clamp(21px, 6.2vw, 27px); line-height: 1.4; max-width: 58%; letter-spacing: -.01em; }
.hero h2 em { font-style: normal; color: var(--blue); }
.hero p { font-size: 13px; color: var(--ink-2); margin-top: 10px; max-width: 58%; line-height: 1.85; }
.hero-pipe { position: absolute; inset-inline-end: -8px; top: 20px; width: clamp(120px, 38vw, 172px); stroke: none; }
.hero-pipe .drop { animation: drip 2.4s ease-in infinite; }
.hero-pipe .d2 { animation-delay: 1.1s; }
@keyframes drip { 0% { transform: translateY(-6px); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }

/* Section heads */
.sec { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 28px 6px 14px; }
.sec h3 { font-weight: 800; font-size: 18px; }
.sec-meta { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); unicode-bidi: isolate; }
.link { font-size: 12.5px; font-weight: 600; color: var(--blue); padding: 8px 14px; border-radius: 999px; box-shadow: var(--raise-xs); white-space: nowrap; }
.link:active { box-shadow: var(--press-sm); }
.hint { font-size: 13px; color: var(--ink-2); margin: -6px 6px 14px; }

/* Family chips — raised keys; the chosen one is pressed in */
.chips { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x proximity; margin-inline: -16px; padding: 6px 16px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-width: 82px; scroll-snap-align: start; border-radius: 22px; padding: 12px 10px 10px; text-align: center; font-size: 12px; font-weight: 600; color: var(--ink-2); transition: box-shadow .25s, color .2s; }
.chip.glass { box-shadow: var(--raise-sm); }
.chip .ic { display: grid; place-items: center; width: 38px; height: 38px; margin: 0 auto 7px; border-radius: 50%; box-shadow: var(--press-sm); font-family: var(--f-mono); font-weight: 500; font-size: 10.5px; color: var(--ink-2); }
.chip.glass[aria-selected="true"] { box-shadow: var(--press-sm); color: var(--blue); }
.chip[aria-selected="true"] .ic { box-shadow: var(--raise-xs); color: var(--blue); }

/* Calculator card */
.card { border-radius: var(--r-lg); padding: 20px 18px; }
.card.compact { padding: 16px; margin-bottom: 16px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 5px; border-radius: 999px; box-shadow: var(--press-sm); }
.seg button { min-height: 38px; padding: 0 12px; border-radius: 999px; font-weight: 600; font-size: 13.5px; color: var(--ink-2); transition: box-shadow .25s, color .2s; white-space: nowrap; }
.seg button[aria-checked="true"] { box-shadow: var(--raise-xs); color: var(--blue); }
.std-label { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); margin: 10px 8px 16px; unicode-bidi: plaintext; text-align: start; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; padding-inline: 8px; }
.opt { color: var(--ink-3); font-weight: 400; }
.field input, .field select {
  width: 100%; min-height: 50px; border: 0; outline: 0; border-radius: 16px; padding: 0 16px; background-color: var(--bg); box-shadow: var(--press-sm);
  font-size: 15.5px; font-weight: 600; color: var(--ink); appearance: none; -webkit-appearance: none; transition: box-shadow .2s;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235F6980' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 15px; background-position: left 14px center; padding-inline-end: 38px; cursor: pointer; }
[dir="ltr"] .field select { background-position: right 14px center; }
.field input::placeholder { color: var(--ink-3); font-weight: 400; }
.field input:focus, .field select:focus { box-shadow: var(--press-sm), 0 0 0 2px var(--blue-tint); }
.field input:focus-visible, .field select:focus-visible { outline: none; }
.field input[aria-invalid="true"] { box-shadow: var(--press-sm), 0 0 0 2px rgba(194, 48, 60, .45); }
select option { background: #fff; color: var(--ink); }

.btn {
  margin-top: 20px; width: 100%; min-height: 54px; border-radius: 999px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--f-display); font-weight: 700; font-size: 16px; color: #fff;
  background: linear-gradient(145deg, #3A7BE0, var(--blue-deep));
  box-shadow: 6px 6px 16px var(--blue-glow), -6px -6px 14px var(--hl), inset 1px 1px 0 rgba(255, 255, 255, .25);
  transition: box-shadow .2s;
}
.btn:active { box-shadow: inset 4px 4px 10px rgba(5, 25, 70, .45), -4px -4px 10px var(--hl); }
.btn svg { width: 19px; height: 19px; stroke-width: 2.5; }
[dir="ltr"] .btn svg { transform: scaleX(-1); }
.status { min-height: 20px; margin-top: 12px; font-size: 12.5px; text-align: center; color: var(--ink-3); }
.status.err { color: var(--danger); }

/* Result — numbers live in pressed wells */
.res { margin-top: 18px; border-radius: var(--r-lg); padding: 18px; transition: box-shadow .4s; }
.res.glass.flash { box-shadow: var(--raise), 0 0 0 2px var(--blue-tint); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.st { text-align: center; padding: 12px 4px 10px; border-radius: 18px; box-shadow: var(--press-sm); min-width: 0; }
.st svg { width: 18px; height: 18px; color: var(--blue); }
.st b { display: block; font-family: var(--f-mono); font-weight: 500; font-size: 12.5px; margin-top: 4px; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.st small { font-size: 10.5px; color: var(--ink-3); }
.rows { margin-top: 14px; padding-inline: 4px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 4px; border-top: 1px solid rgba(150, 165, 192, .25); font-size: 13.5px; color: var(--ink-2); }
.row:first-child { border-top: 0; }
.row b { font-family: var(--f-mono); font-weight: 500; color: var(--ink); unicode-bidi: plaintext; }
.tot { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; border-radius: 22px; box-shadow: var(--press); }
.tot small { font-size: 12.5px; color: var(--ink-2); font-weight: 600; flex: none; }
.tot b { font-family: var(--f-mono); font-weight: 500; font-size: clamp(18px, 5.4vw, 22px); color: var(--blue); text-align: end; unicode-bidi: plaintext; overflow-wrap: anywhere; min-width: 0; }

/* Tables — sunk into the surface */
.table-wrap { border-radius: 24px; overflow: auto; max-height: 64vh; padding: 6px; }
.table-wrap.glass { box-shadow: var(--press); }
#preview { max-height: none; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; text-align: center; }
th, td { padding: 10px 9px; border-bottom: 1px solid rgba(150, 165, 192, .22); white-space: nowrap; }
td { font-family: var(--f-mono); }
thead th { position: sticky; top: 0; background: var(--bg); color: var(--ink-3); font-weight: 600; font-size: 11px; z-index: 1; }
tbody th { color: var(--ink); font-weight: 600; text-align: start; position: sticky; inset-inline-start: 0; background: var(--bg); font-family: var(--f-mono); font-size: 12px; }
td small { display: block; color: var(--ink-3); font-size: 10px; }
td.na { color: rgba(135, 145, 166, .5); }
tr.hl th, tr.hl td { color: var(--blue); }
td.hl { border-radius: 12px; box-shadow: var(--raise-xs); background: var(--bg); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }

/* Settings */
.about { font-size: 13.5px; line-height: 2; color: var(--ink-2); }
.sources { margin-top: 12px; padding-inline-start: 18px; font-family: var(--f-mono); font-size: 11.5px; line-height: 2; color: var(--ink-3); direction: ltr; text-align: left; }

.privacy-row { margin-top: 16px; }
.privacy-row .link { display: inline-block; text-decoration: none; }

/* Footer */
.foot { margin-top: 30px; text-align: center; font-size: 13px; color: var(--ink-2); line-height: 2.2; }
.foot b { color: var(--ink); }
.dd-badge { display: flex; width: max-content; margin: 8px auto 0; align-items: center; gap: 9px; padding: 7px 16px 7px 8px; border-radius: 999px; text-decoration: none; color: var(--ink); direction: ltr; transition: box-shadow .2s; }
.dd-badge.glass { box-shadow: var(--raise-sm); }
.dd-badge.glass:active { box-shadow: var(--press-sm); }
.dd-badge img { border-radius: 50%; }
.dd-badge small { font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-3); }

/* Bottom navigation — raised bar, active tab pressed in */
.nav {
  position: fixed; z-index: 6; inset-inline: 0; bottom: calc(var(--safe-b) + 12px);
  width: min(528px, calc(100% - 32px)); margin: 0 auto; border-radius: 999px; display: flex; justify-content: space-around; gap: 4px; padding: 7px;
}
.nav button { flex: 1; min-height: 54px; border-radius: 999px; font-size: 10.5px; color: var(--ink-3); font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; transition: box-shadow .2s, color .2s; }
.nav .i { display: grid; place-items: center; }
.nav svg { width: 20px; height: 20px; }
.nav button.on { color: var(--blue); box-shadow: var(--press-sm); }

.view { animation: rise .35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; transition: none !important; }
}
