/* Kalich Share — shared stylesheet
 * Design tokens extracted from the live Open WebUI build
 * (ai.kalich.net, container open-webui, /app/build/_app/immutable/assets/0.*.css).
 * Tailwind v4 oklch grays converted to sRGB hex for maximum client support.
 *
 * DEFAULT = OWUI LIGHT appearance (white page, gray-50 surfaces, dark text,
 * black primary button) — this is how ai.kalich.net reads on Jason's devices.
 * prefers-color-scheme: dark flips the same roles to the OWUI dark palette.
 *
 * Light/dark pairings below are the literal class pairs OWUI ships, e.g.
 *   bg-white  dark:bg-gray-900     page
 *   bg-gray-50 dark:bg-gray-850    surface
 *   border-gray-100 dark:border-gray-800
 *   text-gray-900 dark:text-gray-100
 *   text-gray-600 dark:text-gray-400
 *   bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black
 *
 * Single source of truth: restyling this file restyles every past share link.
 */

:root {
  color-scheme: light dark;

  /* OWUI gray scale: oklch(L% 0 0) -> hex */
  --gray-50:  #f8f8f8;
  --gray-100: #ebebeb;
  --gray-200: #e4e4e4;
  --gray-300: #cecece;
  --gray-400: #b4b4b4;
  --gray-500: #9b9b9b;
  --gray-600: #666666;
  --gray-700: #4d4d4d;
  --gray-800: #333333;
  --gray-850: #262626;
  --gray-900: #161616;
  --gray-950: #0d0d0d;

  /* Semantic roles — OWUI LIGHT theme (default) */
  --bg:            #ffffff;
  --surface:       var(--gray-50);
  --surface-hover: var(--gray-100);
  --inset:         #ffffff;
  --border:        var(--gray-100);
  --text:          var(--gray-900);
  --text-muted:    var(--gray-600);
  --text-faint:    var(--gray-500);
  --meta-sep:      var(--gray-300);

  --btn-primary-bg:       #000000;
  --btn-primary-fg:       #ffffff;
  --btn-primary-bg-hover: var(--gray-900);

  --mark-bg: #000000;
  --mark-fg: #ffffff;

  --footer-text: var(--gray-500);
  --footer-link: var(--gray-600);

  /* OWUI radii */
  --radius-sm:  0.25rem;
  --radius-md:  0.375rem;
  --radius-lg:  0.5rem;
  --radius-xl:  0.75rem;
  --radius-2xl: 1rem;
  --radius-3xl: 1.5rem;

  /* OWUI font stacks */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Vazirmatn", ui-sans-serif,
               system-ui, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif,
               "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji",
               "Segoe UI Symbol", "Noto Color Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;
}

/* Semantic roles — OWUI DARK theme (opt-in via OS preference) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            var(--gray-900);
    --surface:       var(--gray-850);
    --surface-hover: var(--gray-800);
    --inset:         var(--gray-950);
    --border:        var(--gray-800);
    --text:          var(--gray-100);
    --text-muted:    var(--gray-400);
    --text-faint:    var(--gray-500);
    --meta-sep:      var(--gray-700);

    --btn-primary-bg:       var(--gray-100);
    --btn-primary-fg:       var(--gray-900);
    --btn-primary-bg-hover: #ffffff;

    --mark-bg: var(--gray-100);
    --mark-fg: var(--gray-900);

    --footer-text: var(--gray-600);
    --footer-link: var(--gray-500);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--font-sans);
  word-break: break-word;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

/* ---------- Layout ---------- */

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
}

.page--center {
  justify-content: center;
  text-align: center;
  min-height: 80vh;
}

/* ---------- Header ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 2rem;
  text-decoration: none;
  color: var(--text);
}

.page--center .brand { justify-content: center; }

.brand__mark {
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  border-radius: var(--radius-lg);
  background-color: var(--mark-bg);
  color: var(--mark-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand__name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Typography ---------- */

h1 {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.lead {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.muted { color: var(--text-muted); }

/* ---------- File card ---------- */

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
}

.file__name {
  margin: 0 0 0.375rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  word-break: break-all;
}

.file__meta {
  margin: 0 0 1.25rem;
  color: var(--text-faint);
  font-size: 0.875rem;
}

.file__meta span + span::before {
  content: "·";
  margin: 0 0.5rem;
  color: var(--meta-sep);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn--primary {
  width: 100%;
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

.btn--primary:hover { background-color: var(--btn-primary-bg-hover); }

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

.btn--ghost:hover {
  background-color: var(--surface-hover);
  color: var(--text);
}

.btn__icon { width: 1.125rem; height: 1.125rem; flex: 0 0 auto; }

/* ---------- Preview ---------- */

.preview {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background-color: var(--inset);
}

.preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 32rem;
  object-fit: contain;
}

.preview iframe {
  display: block;
  width: 100%;
  height: 34rem;
  border: 0;
}

/* ---------- Raw link ---------- */

.rawlink {
  margin-top: 1.25rem;
  font-size: 0.8125rem;
  color: var(--text-faint);
}

.rawlink code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  background-color: var(--inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.125rem 0.375rem;
  word-break: break-all;
}

/* ---------- Footer ---------- */

.footer {
  flex-shrink: 0;
  padding: 1.5rem 1.25rem 2rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--footer-text);
}

.footer a { color: var(--footer-link); text-decoration: none; }
.footer a:hover { color: var(--text-muted); }

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .page { padding: 1.75rem 1rem 2rem; }
  .card { padding: 1.25rem; border-radius: var(--radius-xl); }
  h1 { font-size: 1.25rem; }
  .preview iframe { height: 24rem; }
}
