/* =========================================================================
   GuluStock shared UI layer
   Loaded after each page's own stylesheet so these tokens and component
   refinements win the cascade. Backend behavior is intentionally untouched.
   ========================================================================= */

:root {
  color-scheme: light dark;

  --font-sans: "Manrope", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Sora", "Manrope", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f5f7fb;
  --bg-soft: #edf1f7;
  --card: #ffffff;
  --sidebar: #ffffff;
  --sidebar-2: #eef2f8;
  --border: #e2e7ef;
  --border-2: #ccd5e2;
  --text: #0b1220;
  --text-2: #263348;
  --muted: #5f6b80;
  --hover: #eef3fa;
  --active: #e4edf7;

  --accent: #0e9f6e;
  --accent-ink: #087f59;
  --accent-bg: #eafaf3;
  --accent-fg: #087f59;
  --accent-bd: #b8ead5;

  --crypto: #f59e0b;
  --crypto-ink: #b45309;
  --crypto-bg: #fff7eb;
  --crypto-fg: #b45309;
  --crypto-bd: #fed7aa;

  --ok: #0f8a5f;
  --warn: #b45309;
  --err: #c22a3c;

  --ring: rgba(14, 159, 110, 0.16);
  --ring-c: rgba(245, 158, 11, 0.18);
  --scrollbar: #c8d1de;

  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.05), 0 8px 24px rgba(11, 18, 32, 0.05);
  --shadow-md: 0 2px 4px rgba(11, 18, 32, 0.05), 0 16px 42px rgba(11, 18, 32, 0.10);
  --shadow-lg: 0 4px 8px rgba(11, 18, 32, 0.06), 0 30px 80px rgba(11, 18, 32, 0.16);

  --radius-sm: 0px;
  --radius: 0px;
  --radius-lg: 0px;
}

body[data-app="bursa"] {
  --accent: #0e9f6e;
  --accent-ink: #087f59;
  --accent-bg: #eafaf3;
  --accent-fg: #087f59;
  --accent-bd: #b8ead5;
}

body[data-app="crypto"] {
  --accent: #f59e0b;
  --accent-ink: #c76d00;
  --accent-bg: #fff7eb;
  --accent-fg: #b45309;
  --accent-bd: #fed7aa;
}

body[data-app="marketing"] {
  --accent: #0e9f6e;
  --accent-ink: #087f59;
  --accent-bg: #eafaf3;
  --accent-fg: #087f59;
  --accent-bd: #b8ead5;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1a;
    --bg-soft: #0e1522;
    --card: #111a29;
    --sidebar: #0d1522;
    --sidebar-2: #151f30;
    --border: #1f2b3d;
    --border-2: #2b3b52;
    --text: #e8eff9;
    --text-2: #c4d0e2;
    --muted: #8fa0b8;
    --hover: #172235;
    --active: #1d2b42;

    --accent: #22c088;
    --accent-ink: #56d8aa;
    --accent-bg: #0b2e24;
    --accent-fg: #6ee7b7;
    --accent-bd: #115f46;

    --crypto: #f5a623;
    --crypto-ink: #f6b84a;
    --crypto-bg: #2a1d0a;
    --crypto-fg: #f7b955;
    --crypto-bd: #63431a;

    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;

    --ring: rgba(34, 192, 136, 0.22);
    --ring-c: rgba(245, 166, 35, 0.24);
    --scrollbar: #26364d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28), 0 8px 24px rgba(0, 0, 0, 0.20);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.28), 0 18px 46px rgba(0, 0, 0, 0.26);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.34), 0 32px 86px rgba(0, 0, 0, 0.36);
  }

  body[data-app="bursa"] {
    --accent: #22c088;
    --accent-ink: #56d8aa;
    --accent-bg: #0b2e24;
    --accent-fg: #6ee7b7;
    --accent-bd: #115f46;
  }

  body[data-app="crypto"] {
    --accent: #f5a623;
    --accent-ink: #f6b84a;
    --accent-bg: #2a1d0a;
    --accent-fg: #f7b955;
    --accent-bd: #63431a;
  }
}

/* Browser surfaces carry the design too. */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: -0.011em;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  caret-color: var(--accent);
}

@media (max-width: 720px) {
  input,
  textarea,
  select {
    font-size: 16px;
  }
}

body {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.sidebar {
  padding-top: max(16px, env(safe-area-inset-top));
}

.content {
  padding-bottom: max(104px, calc(env(safe-area-inset-bottom) + 88px));
}

h1,
h2,
h3,
h4,
h5 {
  font-family: var(--font-display);
  letter-spacing: -0.035em;
  text-wrap: balance;
  color: var(--text);
}

p {
  text-wrap: pretty;
}

::selection {
  background: var(--accent-bg);
  color: var(--accent-fg);
}

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

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

/* Custom scrollbars keep wide data tables and sidebars feeling deliberate. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border: 2px solid transparent;
  border-radius: 0;
  background-clip: padding-box;
}

/* -------------------------------------------------------------------------
   App shell (Bursa + Crypto)
   ------------------------------------------------------------------------- */
body[data-app="bursa"] .app,
body[data-app="crypto"] .app {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 232px minmax(0, 1fr);
}

@media (max-width: 720px) {
  body[data-app="bursa"] .app,
  body[data-app="crypto"] .app {
    grid-template-columns: 1fr;
  }

  body[data-app="bursa"] .sidebar,
  body[data-app="crypto"] .sidebar {
    position: relative;
    top: auto;
    height: auto;
    overflow-y: visible;
  }
}

body[data-app="bursa"] .sidebar,
body[data-app="crypto"] .sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar);
  border-color: var(--border);
}

body[data-app="bursa"] .content,
body[data-app="crypto"] .content {
  width: 100%;
  max-width: 1680px;
  padding: clamp(26px, 3.2vw, 46px) clamp(20px, 3.4vw, 52px) 104px;
}

@media (max-width: 720px) {
  body[data-app="bursa"] .content,
  body[data-app="crypto"] .content {
    padding: 24px 18px 72px;
  }
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin: 0 0 28px;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(28px, 3.4vw, 38px);
  font-weight: 700;
  line-height: 1.05;
}

.page-header p {
  margin: 9px 0 0;
  max-width: 680px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

@media (max-width: 720px) {
  .page-header {
    align-items: flex-start;
    margin-bottom: 22px;
  }
}

/* Sidebar navigation */
.sidebar .brand {
  margin-bottom: 18px;
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-text small {
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
}

.nav-section {
  margin-top: 6px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.nav-item {
  border-radius: 0;
  margin-bottom: 3px;
  padding: 9px 11px;
  font-weight: 550;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  background: var(--hover);
  color: var(--text);
  transform: translateX(1px);
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-fg);
  box-shadow: inset 0 0 0 1px var(--accent-bd);
}

.nav-icon {
  width: 17px;
  height: 17px;
  stroke-width: 1.7;
}

.asset-switch {
  margin-bottom: 8px;
  padding: 4px;
  background: var(--bg-soft);
  border-color: var(--border);
  border-radius: 0;
}

.asset-opt {
  border-radius: 0;
}

.asset-opt.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------------------
   Cards, tables, and common components
   ------------------------------------------------------------------------- */
.card,
.source-card,
.run-card,
.bt-card,
.stage-card,
.pillar,
.feat,
.mkt,
.tile,
.browserframe,
.table-wrap,
.chart-wrap,
.journal-wrap,
.proto-sec {
  border-color: var(--border);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.dt-stat-strip {
  background: var(--card);
  border-color: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.empty {
  background: var(--card);
  border-color: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.note {
  background: var(--accent-bg);
  border-color: var(--accent-bd);
  border-radius: var(--radius);
  color: var(--text-2);
}

.rules-md {
  background: var(--bg-soft);
  border-color: var(--border);
  border-radius: var(--radius-sm);
}

.source-card:hover,
.run-card:hover,
.bt-card:hover,
.stage-card:hover,
.pillar:hover,
.feat:hover,
.mkt:hover,
.tile:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

body[data-app="bursa"] .content .card:hover,
body[data-app="crypto"] .content .card:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.source-card,
.run-card,
.bt-card,
.stage-card,
.pillar,
.feat,
.mkt,
.tile {
  border-radius: var(--radius);
}

.table-wrap,
.chart-wrap,
.journal-wrap {
  border-radius: var(--radius);
  overflow: hidden;
}

@media (max-width: 720px) {
  .table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
}

.section {
  margin-bottom: 40px;
}

.section-title {
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Data tables */
table {
  font-variant-numeric: tabular-nums;
}

th,
td {
  border-color: var(--border);
}

th {
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--bg-soft);
}

td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-2);
}

tbody tr {
  transition: background-color 130ms ease;
}

tbody tr:hover td {
  background: var(--hover);
}

td:first-child,
th:first-child {
  padding-left: 16px;
}

td:last-child,
th:last-child {
  padding-right: 16px;
}

td[data-col="refpx"] {
  cursor: help;
}

.mono,
code,
.src-ep,
.rules-md {
  font-family: var(--font-mono);
}

.card-value,
.dt-stat-value,
.run-stats .val,
.bt-metrics b,
.stage-pct,
.pf-n {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}

.card-value,
.dt-stat-value {
  color: var(--text);
}

.card-label,
.dt-stat-label,
.run-stats .lbl {
  font-weight: 700;
}

/* Buttons and controls */
.btn,
.status-pill,
.tab-btn,
.view-toggle a,
.proto-pill,
.ai-chip {
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
}

.btn {
  border-radius: 0;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 26%, transparent);
}

.btn-primary:hover {
  background: var(--accent-ink);
  transform: translateY(-1px);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 32%, transparent);
}

.btn-crypto {
  background: var(--crypto);
  color: #ffffff;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--crypto) 28%, transparent);
}

.btn-crypto:hover {
  background: var(--crypto-ink);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-fg);
  background: var(--accent-bg);
}

.tab-btn {
  font-weight: 650;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-count {
  font-weight: 700;
}

.status-pill,
.view-toggle a {
  border-radius: 0;
}

.status-pill {
  font-weight: 650;
  border-color: var(--border);
  background: var(--card);
  color: var(--text-2);
}

.status-pill:hover {
  border-color: var(--accent);
  color: var(--accent-fg);
  background: var(--accent-bg);
}

.analysis-col-row:hover {
  background: var(--hover);
  border-color: var(--border);
}

.analysis-col-row button:hover,
.analysis-preset:hover {
  border-color: var(--accent);
  color: var(--accent-fg);
  background: var(--accent-bg);
}

.view-toggle {
  background: var(--bg-soft);
  border-color: var(--border);
  border-radius: 0;
}

.view-toggle a.active {
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

input,
textarea,
select {
  border-radius: 0;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

@media (pointer: coarse) {
  .btn,
  .nav-item,
  .tab-btn,
  .status-pill,
  .view-toggle a,
  .asset-opt,
  .ai-chip,
  .cm-tf,
  .chartmodal-close,
  .faq summary {
    min-height: 44px;
  }
}

/* -------------------------------------------------------------------------
   Modal anatomy
   Every modal shell is a column: header and footer are fixed, body scrolls.
   ------------------------------------------------------------------------- */
.chartmodal,
.bt-modal,
.proto-modal,
#cookies-modal-panel,
#bt-detail-modal [role="document"],
#analysis-cols-modal [role="document"],
.us-modal-card {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.chartmodal {
  max-height: 96vh;
}

.proto-modal {
  max-height: 88vh;
}

.bt-modal {
  max-height: calc(100vh - 48px);
}

.bt-back.is-open {
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 24px;
}

#bt-detail-modal {
  align-items: center !important;
  overflow: hidden !important;
}

.us-modal-card {
  max-height: calc(100vh - 48px);
}

.us-modal-card > form {
  display: flex !important;
  flex-direction: column !important;
  min-height: 0;
  height: 100%;
}

.chartmodal-head,
.chartmodal-legend,
.bt-modal-head,
.proto-head,
.ai-head,
.ai-foot,
.us-modal-head,
.us-modal-foot {
  flex-shrink: 0;
}

#cookies-modal-panel > div:first-child,
#bt-detail-modal [role="document"] > div:first-child,
#analysis-cols-modal [role="document"] > div:first-child,
#analysis-cols-modal [role="document"] > div:nth-child(2),
#analysis-cols-modal [role="document"] > div:last-child {
  flex-shrink: 0;
}

.chartmodal-body,
.bt-modal-body,
.proto-body,
#bt-detail-body,
#analysis-cols-list,
.us-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

#cookies-modal-panel > div:nth-child(2) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

#bt-detail-skeleton {
  flex: 0 0 auto;
}

.chartmodal-foot {
  border-top: 1px solid var(--border);
}

/* AI chat is a two-pane modal. Keep each pane's head/foot fixed and let only
   its message list / conversation list scroll. */
.ai-modal {
  overflow: hidden;
}

.ai-pane-list,
.ai-pane-thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ai-list,
.ai-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* -------------------------------------------------------------------------
   Marketing site refinements
   ------------------------------------------------------------------------- */
body[data-app="marketing"] .wrap {
  max-width: 1180px;
}

body[data-app="marketing"] header.nav {
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  border-bottom-color: var(--border);
}

body[data-app="marketing"] .hero {
  padding-top: clamp(68px, 8vw, 104px);
  padding-bottom: clamp(56px, 7vw, 88px);
}

body[data-app="marketing"] .hero h1 {
  max-width: 13ch;
}

body[data-app="marketing"] .hero .lead {
  max-width: 60ch;
}

body[data-app="marketing"] .glass {
  box-shadow: var(--shadow-lg);
}

body[data-app="marketing"] .markets,
body[data-app="marketing"] .grid,
body[data-app="marketing"] .mosaic {
  gap: 22px;
}

body[data-app="marketing"] .mkt {
  border-radius: 0;
}

body[data-app="marketing"] .tile {
  border-radius: 0;
}

body[data-app="marketing"] .cta {
  border-radius: 0;
  box-shadow: var(--shadow-lg);
}

body[data-app="marketing"] .faq details {
  box-shadow: var(--shadow-sm);
}

body[data-app="marketing"] .proof {
  padding: 30px 14px;
}

/* Remove gradient-text tell on the landing hero. The committed emphasis stays
   on weight and scale, with the accent used as a solid color. */
body[data-app="marketing"] .hero h1 .grad,
body[data-app="marketing"] .grad {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  color: var(--accent);
  -webkit-text-fill-color: currentColor;
}

/* Respect reduced motion without removing purposeful feedback. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
