/* Karigar Workbench — Sahkarmi's shared design layer.
   Loaded after each page's own stylesheet. Decoration only: it never changes text, headings,
   links or metadata. Every decorative element is aria-hidden and pointer-events: none.
   Motion is off under prefers-reduced-motion. Works in the light and dark themes. */

:root {
  --wb-saffron: #e8772e;
  --wb-marigold: #f2b705;
  --wb-navy: #1e2a5a;
  --wb-grid: rgba(30, 42, 90, 0.045);
  --wb-grid-major: rgba(30, 42, 90, 0.09);
  --wb-guide: rgba(232, 119, 46, 0.9);
  --wb-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --wb-ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --wb-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --wb-grid: rgba(243, 239, 230, 0.05); --wb-grid-major: rgba(243, 239, 230, 0.1); }
}
:root[data-theme="dark"] { --wb-grid: rgba(243, 239, 230, 0.05); --wb-grid-major: rgba(243, 239, 230, 0.1); }

/* ---------------------------------------------------------------- film grain */
.wb-grain {
  position: fixed; inset: 0; z-index: 2147483000; pointer-events: none; opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (max-width: 900px), (pointer: coarse) { .wb-grain { display: none; } }

/* ---------------------------------------------------------------- cutting-mat hero */
.wb-mat { position: relative; isolation: isolate; }
.wb-rel { position: relative; }
.wb-mat > .wb-matbg {
  position: absolute; inset: -28px calc(-1 * clamp(10px, 3vw, 48px)); z-index: -1; pointer-events: none;
  border-radius: 28px; overflow: hidden;
  background:
    linear-gradient(var(--wb-grid-major) 1px, transparent 1px) 0 0 / 120px 120px,
    linear-gradient(90deg, var(--wb-grid-major) 1px, transparent 1px) 0 0 / 120px 120px,
    linear-gradient(var(--wb-grid) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--wb-grid) 1px, transparent 1px) 0 0 / 24px 24px;
  -webkit-mask-image: radial-gradient(120% 95% at 30% 35%, #000 35%, transparent 78%);
  mask-image: radial-gradient(120% 95% at 30% 35%, #000 35%, transparent 78%);
}
/* ruler along the top edge of the mat */
.wb-mat > .wb-matbg::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 14px;
  background:
    linear-gradient(90deg, var(--wb-grid-major) 1px, transparent 1px) 0 0 / 120px 14px,
    linear-gradient(90deg, var(--wb-grid-major) 1px, transparent 1px) 0 0 / 24px 7px;
  background-repeat: repeat-x;
}

/* ---------------------------------------------------------------- measurement guides */
.wb-spec { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.wb-spec i { position: absolute; display: block; }
.wb-spec .c { width: 14px; height: 14px; border-color: var(--wb-guide); border-style: solid; border-width: 0; }
.wb-spec .tl { left: -10px; top: -10px; border-left-width: 1.5px; border-top-width: 1.5px; }
.wb-spec .tr { right: -10px; top: -10px; border-right-width: 1.5px; border-top-width: 1.5px; }
.wb-spec .bl { left: -10px; bottom: -10px; border-left-width: 1.5px; border-bottom-width: 1.5px; }
.wb-spec .br { right: -10px; bottom: -10px; border-right-width: 1.5px; border-bottom-width: 1.5px; }
.wb-spec .hx { left: 0; right: 0; top: -22px; height: 1px; background: var(--wb-guide); transform-origin: left; }
.wb-spec .hx::before, .wb-spec .hx::after { content: ""; position: absolute; top: -4px; width: 1px; height: 9px; background: var(--wb-guide); }
.wb-spec .hx::before { left: 0; } .wb-spec .hx::after { right: 0; }
.wb-spec .vy { top: 0; bottom: 0; left: -22px; width: 1px; background: var(--wb-guide); transform-origin: top; }
.wb-spec .vy::before, .wb-spec .vy::after { content: ""; position: absolute; left: -4px; width: 9px; height: 1px; background: var(--wb-guide); }
.wb-spec .vy::before { top: 0; } .wb-spec .vy::after { bottom: 0; }
.wb-spec .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wb-guide); box-shadow: 0 0 0 4px rgba(232, 119, 46, 0.18); }
.wb-spec .d1 { right: 18px; top: -25px; }
@media (max-width: 720px) { .wb-mat > .wb-matbg { inset: -20px -8px; opacity: 0.6; } .wb-spec .vy, .wb-spec .d1, .wb-spec .hx { display: none; } .wb-spec .c { width: 10px; height: 10px; } }

/* draw-in */
.wb-anim .wb-spec .hx { transform: scaleX(0); transition: transform 1.1s var(--wb-ease) 0.2s; }
.wb-anim .wb-spec .vy { transform: scaleY(0); transition: transform 1.1s var(--wb-ease) 0.35s; }
.wb-anim .wb-spec .c, .wb-anim .wb-spec .dot { opacity: 0; transition: opacity 0.6s ease 0.9s; }
.wb-anim .wb-drawn .wb-spec .hx { transform: none; }
.wb-anim .wb-drawn .wb-spec .vy { transform: none; }
.wb-anim .wb-drawn .wb-spec .c, .wb-anim .wb-drawn .wb-spec .dot { opacity: 1; }

/* ---------------------------------------------------------------- headings: chapters + measured rule */
.wb-page main { counter-reset: wb-ch; }
.wb-page main h2:not(.wb-skip) { counter-increment: wb-ch; }
.wb-page main h2:not(.wb-skip)::before {
  content: counter(wb-ch, decimal-leading-zero) " \2014";
  display: block; margin-bottom: 6px;
  font: 600 11.5px/1 var(--wb-mono); letter-spacing: 0.18em; color: var(--wb-saffron);
}
.wb-page main h1 { letter-spacing: -0.022em; text-wrap: balance; }
.wb-page main h2 { letter-spacing: -0.012em; text-wrap: balance; }
.wb-page .eyebrow, .wb-page .crumbs { font-family: var(--wb-mono); letter-spacing: 0.1em; text-transform: uppercase; font-size: 11.5px; }
.wb-page .crumbs a { text-decoration-color: rgba(232, 119, 46, 0.5); }

.wb-page main h2.wb-num:not(.wb-skip)::before { display: none; }

/* ---------------------------------------------------------------- cards: lift + spotlight */
.wb-spot { position: relative; transition: transform 0.45s var(--wb-ease), box-shadow 0.45s var(--wb-ease), border-color 0.3s; }
.wb-spot::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(232, 119, 46, 0.13), transparent 45%);
  transition: opacity 0.35s;
}
@media (hover: hover) and (pointer: fine) {
  .wb-spot:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -18px rgba(30, 42, 90, 0.35); border-color: rgba(232, 119, 46, 0.45); }
  .wb-spot:hover::after { opacity: 1; }
}

/* ---------------------------------------------------------------- buttons */
.wb-page .btn, .wb-mag { transition: transform 0.35s var(--wb-spring), box-shadow 0.3s, filter 0.2s; will-change: transform; }
.wb-page .btn:not(.btn-ghost) { box-shadow: 0 10px 24px -10px rgba(232, 119, 46, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.wb-page .btn:not(.btn-ghost):hover { filter: saturate(1.08) brightness(1.04); }
.wb-page .btn:active { transform: scale(0.97) !important; }

/* ---------------------------------------------------------------- header glass */
.wb-page body > header:first-of-type {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg, #fbf7f0) 78%, transparent);
}
@media (min-width: 901px) and (pointer: fine) {
  .wb-page body > header:first-of-type { -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); }
}

.wb-page body { overflow-x: clip; }

/* logo tick-ring */
.wb-ring { position: relative; display: inline-grid; place-items: center; }
.wb-ring > svg.wb-ticks { position: absolute; inset: -7px; width: calc(100% + 14px) !important; height: calc(100% + 14px) !important; pointer-events: none; color: var(--wb-saffron); opacity: 0.55; }
.wb-anim .wb-ring > svg.wb-ticks { animation: wb-spin 28s linear infinite; }
.wb-ring:hover > svg.wb-ticks { opacity: 1; }
@keyframes wb-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- reveal on scroll */
.wb-anim .wb-rv { opacity: 0; transform: translateY(22px); transition: opacity 0.8s var(--wb-ease), transform 0.9s var(--wb-ease); transition-delay: var(--wb-d, 0ms); }
.wb-anim .wb-rv.wb-in { opacity: 1; transform: none; }

/* ---------------------------------------------------------------- scroll rail (ruler) */
.wb-rail {
  position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 40; height: min(56vh, 460px); width: 26px;
  pointer-events: none; opacity: 0; transition: opacity 0.5s;
}
.wb-rail.on { opacity: 1; }
.wb-rail::before {
  content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 10px;
  background: linear-gradient(var(--wb-grid-major) 1px, transparent 1px) 0 0 / 10px 12px;
}
.wb-rail::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 1px; background: var(--wb-grid-major); }
.wb-rail .t { position: absolute; right: 0; width: 18px; height: 1.5px; background: var(--wb-grid-major); pointer-events: auto; cursor: pointer; }
.wb-rail .t::before { content: ""; position: absolute; inset: -6px 0; }
.wb-rail .t.past { background: var(--wb-saffron); }
.wb-rail .k { position: absolute; right: -3px; width: 7px; height: 7px; margin-top: -3px; border-radius: 50%; background: var(--wb-saffron); box-shadow: 0 0 0 4px rgba(232, 119, 46, 0.2); }
.wb-rail .lbl {
  position: absolute; right: 30px; transform: translateY(-50%); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
  font: 600 10.5px/1.6 var(--wb-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--wb-saffron);
  background: color-mix(in srgb, var(--bg, #fbf7f0) 85%, transparent); padding: 2px 8px; border-radius: 4px;
}
@media (max-width: 1180px) { .wb-rail { display: none; } }

/* thin progress bar for small screens */
.wb-prog { position: fixed; left: 0; top: 0; height: 2px; width: 100%; z-index: 60; pointer-events: none; transform-origin: left; transform: scaleX(0); background: linear-gradient(90deg, var(--wb-saffron), var(--wb-marigold)); }
@media (min-width: 1181px) { .wb-prog { display: none; } }

/* ---------------------------------------------------------------- footer wordmark */
.wb-page footer { position: relative; overflow: hidden; }
.wb-page footer::after {
  content: "Sahkarmi"; display: block; margin: 36px 0 -0.24em; text-align: center; pointer-events: none;
  font: 800 clamp(64px, 19vw, 260px)/0.9 "Baloo 2", "Mukta", sans-serif; letter-spacing: -0.04em;
  color: transparent; -webkit-text-stroke: 1px rgba(232, 119, 46, 0.35);
  background: linear-gradient(180deg, rgba(232, 119, 46, 0.16), transparent 75%); -webkit-background-clip: text; background-clip: text;
}

/* tables and code get the workbench edge */
.wb-page main pre { border-left: 3px solid var(--wb-saffron); }

@media (prefers-reduced-motion: reduce) {
  .wb-spot, .wb-page .btn, .wb-mag { transition: none; }
  .wb-ring > svg.wb-ticks { animation: none !important; }
}
@media print { .wb-grain, .wb-rail, .wb-prog, .wb-spec, .wb-matbg { display: none !important; } .wb-page footer::after { display: none; } }

/* ---------------------------------------------------------------- responsive fixes (pre-existing overflow) */
/* Long words, URLs and code never push the page sideways. */
main a, main code, main td, main li, main p { overflow-wrap: anywhere; }
main table:not(.resp) { max-width: 100%; }
/* Buttons may wrap onto two lines on very small phones. */
@media (max-width: 400px) {
  main .btn, footer .btn { white-space: normal; max-width: 100%; text-align: center; justify-content: center; }
  .wb-page body > header nav { flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; }
  .wb-page body > header .wrap { flex-wrap: wrap; }
}
/* Savings tables: between phone card layout and desktop, scroll inside the table. */
@media (min-width: 721px) and (max-width: 1040px) {
  table.resp { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
/* Home header on 320–360 px phones: tighter spacing, smaller brand. */
@media (max-width: 360px) {
  .site-header .wrap { gap: 6px !important; padding-inline: 10px; }
  .site-header .header-actions { gap: 6px !important; }
  .site-header .brand small, .site-header .brand .brand-sub { display: none; }
  .site-header .site-lang-btn { padding-inline: 8px; min-width: 40px; justify-content: center; }
  .site-header .site-lang-btn b, .site-header .site-lang-btn svg:last-child { display: none; }
  .site-header .brand { font-size: 0.92em; }
}
.letterbox, .cine-title-card { max-width: 100vw; }
