/* ============================================================
   Hectum Journal — global page styles
   (Component-level styling lives inline inside app.jsx;
    this file handles the page shell, fonts, scrollbars and
    cross-device responsiveness.)
   ============================================================ */

/* Theme surface tokens (overridden at runtime by the active theme). */
:root {
  --bg: #050a12;
  --card: #0d1117;
  --panel: #111827;
  --border: #1f2937;
  --text: #e5e7eb;
  --sub: #6b7280;
  --accent: #00d4aa;
}

* {
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #050a12;
  color: #e5e7eb;
  font-family: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root {
  min-height: 100vh;
  /* Use the dynamic viewport unit where supported so mobile browser
     chrome (and the Telegram in-app webview) don't cause clipping. */
  min-height: 100dvh;
}

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

/* Prevent iOS Safari auto-zoom on focus: inputs must be >= 16px there. */
@media (max-width: 480px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Nicer dark scrollbars */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #1f2937;
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover {
  background: #374151;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #1f2937 transparent;
}

/* Honour the safe-area on notched / gesture-bar devices. */
.safe-bottom {
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
}

/* Initial loading state, shown until React mounts */
.app-loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #050a12;
  color: #6b7280;
}
.app-loader .spinner {
  width: 38px;
  height: 38px;
  border: 3px solid #1f2937;
  border-top-color: #00d4aa;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.app-loader .label {
  font-size: 13px;
  letter-spacing: 0.06em;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes hj-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Markdown (AI answers) ── */
.md {
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.md > *:first-child {
  margin-top: 0;
}
.md > *:last-child {
  margin-bottom: 0;
}
.md h1,
.md h2,
.md h3,
.md h4 {
  color: var(--text);
  font-weight: 800;
  line-height: 1.3;
  margin: 18px 0 8px;
}
.md h1 {
  font-size: 19px;
}
.md h2 {
  font-size: 17px;
}
.md h3 {
  font-size: 15px;
}
.md h4 {
  font-size: 14px;
}
.md p {
  margin: 0 0 10px;
}
.md ul,
.md ol {
  margin: 0 0 10px;
  padding-left: 22px;
}
.md li {
  margin: 4px 0;
}
.md li::marker {
  color: var(--accent);
}
.md strong {
  color: var(--text);
  font-weight: 700;
}
.md em {
  color: var(--sub);
}
.md a {
  color: #38bdf8;
  text-decoration: none;
}
.md a:hover {
  text-decoration: underline;
}
.md code {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: "DM Mono", ui-monospace, monospace;
  font-size: 0.88em;
  color: var(--accent);
}
.md pre {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0 0 12px;
}
.md pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
}
.md blockquote {
  margin: 0 0 12px;
  padding: 6px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(127, 127, 127, 0.08);
  color: var(--sub);
  border-radius: 0 8px 8px 0;
}
.md hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}
.md table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: 13px;
}
.md th,
.md td {
  border: 1px solid var(--border);
  padding: 7px 10px;
  text-align: left;
}
.md th {
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
}
.md img {
  max-width: 100%;
  border-radius: 8px;
}
