/* Cookmark design tokens (design/tokens.css) */
:root {
  color-scheme: light dark;

  /* Color: light (logo cream, white, ink) */
  --cm-bg: #F4EFE8;
  --cm-surface: #FFFFFF;
  --cm-surface-2: #ECE4D9;
  --cm-ink: #17130F;
  --cm-ink-2: #5E5248;
  --cm-line: #8A7E72;      /* input outlines and the logo edge */
  --cm-card-line: #E3DACE; /* hairline dividers */
  --cm-on-ink: #F4EFE8;
  --cm-danger: #A3301C;
  --cm-focus: #17130F;

  /* Type */
  --cm-font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui,
    -apple-system, "Segoe UI", Roboto, sans-serif;
  --cm-text-xs: 0.8125rem;   /* 13 */
  --cm-text-sm: 0.9375rem;   /* 15 */
  --cm-text-md: 1.0625rem;   /* 17 */
  --cm-text-list: 1.125rem;  /* 18 */
  --cm-text-read: 1.1875rem; /* 19 */
  --cm-text-lg: 1.375rem;    /* 22 */
  --cm-text-xl: 1.875rem;    /* 30 */
  --cm-weight-strong: 700;
  --cm-weight-display: 800;
  --cm-leading-tight: 1.15;
  --cm-leading: 1.45;
  --cm-leading-read: 1.65;

  /* Space (4px base, 20px screen gutter) */
  --cm-space-1: 4px;
  --cm-space-2: 8px;
  --cm-space-3: 12px;
  --cm-space-4: 16px;
  --cm-space-5: 20px;
  --cm-space-6: 24px;
  --cm-space-8: 32px;
  --cm-space-12: 48px;

  /* Shape */
  --cm-stroke: 2px;
  --cm-radius-sm: 12px;
  --cm-radius-md: 16px;
  --cm-radius-lg: 22px;
  --cm-radius-pill: 999px;

  /* Size */
  --cm-tap: 44px;
  --cm-tap-lg: 56px;
  --cm-star: 60px;
  --cm-content: 640px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --cm-bg: #16130F;
    --cm-surface: #25201B;
    --cm-surface-2: #2F2923;
    --cm-ink: #F7ECDE;
    --cm-ink-2: #B8A998;
    --cm-line: #8A7E72;
    --cm-card-line: #332C26;
    --cm-on-ink: #16130F;
    --cm-danger: #FF8E78;
    --cm-focus: #F7ECDE;
  }
}

/* Base */
body {
  margin: 0;
  background: var(--cm-bg);
  color: var(--cm-ink);
  font-family: var(--cm-font);
  font-size: var(--cm-text-md);
  line-height: var(--cm-leading);
}
:focus-visible {
  outline: 3px solid var(--cm-focus);
  outline-offset: 3px;
}
.page {
  max-width: var(--cm-content);
  margin-inline: auto;
  padding-inline: var(--cm-space-5);
}
.card {
  background: var(--cm-surface);
  border-radius: var(--cm-radius-md);
}
/* Every logo, light and dark: a crisp warm-grey edge, 1px on the sides and top and
   2px at the bottom, for a slight raised look. No blur, so it never glows. */
.logo {
  filter: drop-shadow(1px 0 0 var(--cm-line))
          drop-shadow(-1px 0 0 var(--cm-line))
          drop-shadow(0 -1px 0 var(--cm-line))
          drop-shadow(0 2px 0 var(--cm-line));
}
.recipe-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: var(--cm-text-read);
  line-height: var(--cm-leading-read);
  padding: var(--cm-space-5);
  background: var(--cm-surface);
  border-radius: var(--cm-radius-lg);
}
.action-bar {
  position: sticky;
  bottom: 0;
  padding: var(--cm-space-3) var(--cm-space-5)
    calc(var(--cm-space-4) + env(safe-area-inset-bottom));
  background: var(--cm-bg);
  border-top: 1px solid var(--cm-card-line);
}

/* ---------- Shared app styles (screen-specific styles live in *.razor.css) ---------- */
/* Nunito (SIL OFL), Latin subset, variable 400 to 800, self-hosted for offline use */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
}
button, input, textarea {
  font: inherit;
  color: inherit;
}
#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
/* auto margins in a flex column would shrink .page to its content */
#app > .page {
  width: 100%;
  box-sizing: border-box;
  max-width: calc(var(--cm-content) + 2 * var(--cm-space-5));
}
[tabindex="-1"]:focus {
  outline: none;
}
h1, h2, p {
  margin: 0;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.hint {
  color: var(--cm-ink-2);
}
.icon {
  flex: none;
}
/* Each context sets the height; never let a flex row squeeze the logo */
img.logo {
  flex: none;
  width: auto;
}

/* Buttons: ink pill = primary, surface pill = secondary */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  min-height: var(--cm-tap);
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: var(--cm-radius-pill);
  background: var(--cm-ink);
  color: var(--cm-on-ink);
  font-size: 16px;
  font-weight: var(--cm-weight-strong);
  text-decoration: none;
  cursor: pointer;
}
.btn-lg {
  display: flex;
  width: 100%;
  height: var(--cm-tap-lg);
  gap: 10px;
  padding: 0 28px;
  font-size: var(--cm-text-list);
  font-weight: var(--cm-weight-display);
}
.btn-soft {
  height: 48px;
  padding: 0 24px;
  background: var(--cm-surface);
  color: var(--cm-ink);
}

/* Text inputs: the only outlined elements */
.input {
  width: 100%;
  box-sizing: border-box;
  height: 52px;
  padding: 0 var(--cm-space-4);
  border: var(--cm-stroke) solid var(--cm-line);
  border-radius: var(--cm-radius-md);
  background: var(--cm-surface);
  color: var(--cm-ink);
  font-size: var(--cm-text-md);
}
.input::placeholder {
  color: var(--cm-ink-2);
  opacity: 1;
}
.input[aria-invalid="true"] {
  border: 3px solid var(--cm-danger);
}
.input::-webkit-search-cancel-button {
  appearance: none;
}

/* Screens with a back button: Add, Recipe, Review */
.top-bar {
  display: flex;
  align-items: center;
  gap: var(--cm-space-2);
  padding-top: var(--cm-space-3);
}
.top-bar h1 {
  font-size: var(--cm-text-lg);
  font-weight: var(--cm-weight-display);
  letter-spacing: -0.01em;
}
.back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: var(--cm-tap);
  height: var(--cm-tap);
  margin-left: -4px;
  border-radius: var(--cm-radius-pill);
  color: var(--cm-ink);
  font-weight: var(--cm-weight-strong);
  text-decoration: none;
}
.back-label {
  display: none;
}
.action-bar > * {
  max-width: var(--cm-content);
  margin-inline: auto;
}

@media (min-width: 1024px) {
  .top-bar {
    padding-top: var(--cm-space-6);
  }
  .back {
    padding: 0 14px 0 6px;
    margin-left: -6px;
  }
  .back-label {
    display: inline;
  }
}

/* Boot screen in index.html: Blazor sets --blazor-load-percentage(-text) on :root */
.boot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--cm-space-5);
  padding: var(--cm-space-8) var(--cm-space-6);
}
.boot img {
  height: 112px;
}
.boot-bar {
  width: 160px;
  height: 6px;
  border-radius: var(--cm-radius-pill);
  background: var(--cm-surface-2);
  overflow: hidden;
}
.boot-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--blazor-load-percentage, 0%);
  border-radius: var(--cm-radius-pill);
  background: var(--cm-ink);
  transition: width .1s ease-out;
}
.boot-text {
  margin-top: calc(-1 * var(--cm-space-2));
  font-size: var(--cm-text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--cm-ink-2);
}
.boot-text::after {
  content: var(--blazor-load-percentage-text, "Loading");
}
@media (prefers-reduced-motion: reduce) {
  .boot-bar::after { transition: none; }
}

/* Blazor error UI */
#blazor-error-ui {
  background: var(--cm-surface);
  color: var(--cm-ink);
  border-top: 1px solid var(--cm-card-line);
  bottom: 0;
  box-sizing: border-box;
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 1000;
}
#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}
.blazor-error-boundary {
  padding: 1rem;
  border-radius: var(--cm-radius-md);
  background: var(--cm-danger);
  color: var(--cm-on-ink);
}
.blazor-error-boundary::after {
  content: "An error has occurred.";
}
