/* wireframe/content.css - the body-content standard: type scale, spacing, control sizes and
   the shared components (badge, notice, table, toast, link button, button variants).

   Rules:
   - Apps take every font size, spacing and control size from the tokens below (rem, so a host's
     text-size setting scales them). A hard-coded px font size in an app's own CSS is a failure
     (scripts/check_host.py reports them).
   - No bare element selectors (this file is loaded into the same document as the host's, e.g.
     a federated remote inside comb). Text sizing is applied by the `.hive-app` class on the app's
     root element, not on <body>.
   - Colours come only from tokens.css. Load order: tokens.css, chrome.css (if the app uses the
     chrome), components.css, content.css, then the host's own CSS.
   The numbers are comb's de-facto sizes (13px body, 12px small, 11px labels, 14px lead). */

:root {
  /* Type scale (rem; 1rem = 16px at the default root size) */
  --fs-label: 0.6875rem;   /* 11px  uppercase labels, table headers */
  --fs-small: 0.75rem;     /* 12px  hints, table rows, badges, toasts */
  --fs-base: 0.8125rem;    /* 13px  body text */
  --fs-lead: 0.875rem;     /* 14px  subtitles, card titles, buttons */
  --fs-h2: 1rem;           /* 16px */
  --fs-h1: 1.375rem;       /* 22px */
  --fs-stat: 1.625rem;     /* 26px  big numbers */
  --lh-base: 1.45;
  --lh-tight: 1.25;
  /* Spacing scale */
  --space-1: 0.25rem;      /*  4px */
  --space-2: 0.5rem;       /*  8px */
  --space-3: 0.75rem;      /* 12px */
  --space-4: 1rem;         /* 16px */
  --space-5: 1.5rem;       /* 24px */
  --space-6: 2rem;         /* 32px */
  /* Controls */
  --control-h: 2.25rem;    /* 36px */
  --control-h-lg: 2.5rem;  /* 40px */
  --radius: 0.5rem;        /*  8px */
  --radius-lg: 0.75rem;    /* 12px */
}

/* The app's root element: body text size, line height, colour, font. */
.hive-app {
  font-family: var(--font-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
}

/* Text roles (classes, not bare h1/h2) */
.hive-h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); font-weight: 700; color: var(--text-head); margin: 0; }
.hive-h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); font-weight: 700; color: var(--text-head); margin: 0; }
.hive-lead { font-size: var(--fs-lead); color: var(--text); }
.hive-small { font-size: var(--fs-small); }
.hive-muted { color: var(--text-muted); }
.hive-label {
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.hive-stat { font-size: var(--fs-stat); line-height: var(--lh-tight); font-weight: 700; color: var(--text-head); }

/* Buttons: extra variants and sizes for components.css's .hive-btn */
.hive-btn { font-size: var(--fs-lead); height: var(--control-h); border-radius: var(--radius); }
.hive-btn--lg { height: var(--control-h-lg); padding: 0 var(--space-4); }
.hive-btn--danger {
  background: var(--danger-button, var(--danger));
  border-color: var(--danger-button, var(--danger));
  color: var(--on-accent, var(--bg-deep));
}
.hive-btn--danger:hover { filter: brightness(1.08); background: var(--danger-button, var(--danger)); border-color: var(--danger-button, var(--danger)); color: var(--on-accent, var(--bg-deep)); }
.hive-btn--ghost { background: transparent; border-color: transparent; }
.hive-btn--ghost:hover { background: var(--bg-hover); }
.hive-link-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.hive-link-btn:hover { color: var(--primary-hover); }
.hive-link-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* Badge. Tones: --success, --warning, --danger, --info, --accent (default is neutral). */
.hive-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.125rem var(--space-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: var(--lh-tight);
  white-space: nowrap;
}
.hive-badge--success { color: var(--success); background: var(--success-bg); border-color: transparent; }
.hive-badge--warning { color: var(--warning); background: var(--warning-bg); border-color: transparent; }
.hive-badge--danger { color: var(--danger); background: var(--danger-bg); border-color: transparent; }
.hive-badge--info { color: var(--info); background: var(--info-bg); border-color: transparent; }
.hive-badge--accent { color: var(--accent); background: var(--accent-bg); border-color: transparent; }

/* Notice (inline message). Tones: --info, --success, --warning, --danger. Text stays --text for
   readability; the tone is the tint, border and left bar. */
.hive-notice {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--info);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--info-bg);
  color: var(--text);
  font-size: var(--fs-small);
  line-height: var(--lh-base);
}
.hive-notice--success { border-color: var(--success); background: var(--success-bg); }
.hive-notice--warning { border-color: var(--warning); background: var(--warning-bg); }
.hive-notice--danger { border-color: var(--danger); background: var(--danger-bg); }

/* Table */
.hive-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
  color: var(--text);
}
.hive-table th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.hive-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-dim);
  vertical-align: middle;
}
.hive-table tbody tr:hover { background: var(--bg-hover); }

/* Toast (contract 1.4: restyled to bzz's look). The host creates a .hive-toasts container once and
   appends .hive-toast elements to it. One flat box: full 1px border in the tone colour, tinted
   fill, tone-coloured text, no left stripe, no gradient, no shadow. Tones: --success, --warning,
   --danger, --info (default). Dismiss and timing are the host's (read the two variables below).
   Place the stack with <html data-toast-pos="{top,bottom}-{left,center,right}|{top,bottom}-full">;
   no attribute = bottom right, above the footer. The two full positions always push: they take
   the stack out of the overlay and into the page flow: the host puts the container in the
   `toasts-top` slot (first child of the page wrapper (`.page-frame`, else main)) or the `toasts-bottom` slot (last child of the page wrapper),
   and it pushes the page down/up instead of covering it. Top positions sit under the header (--topbar-h). */
:root {
  --toast-duration-ms: 4000;   /* how long a toast stays before it starts to fade (unitless ms) */
  --toast-fade-ms: 200;        /* fade in and fade out time (unitless ms) */
}
.hive-toasts {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--footer-h, 2rem) + var(--space-3));
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(24rem, calc(100vw - 2rem));
}
html[data-toast-pos^="top"] .hive-toasts {
  top: calc(var(--topbar-h, 0px) + var(--space-3));
  bottom: auto;
}
html[data-toast-pos="top-left"] .hive-toasts,
html[data-toast-pos="bottom-left"] .hive-toasts { left: var(--space-4); right: auto; }
html[data-toast-pos="top-center"] .hive-toasts,
html[data-toast-pos="bottom-center"] .hive-toasts {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  align-items: center;
}
/* Full width: the stack spans the page content width (--page-max-width, centred) and each toast
   stretches across it, like home_theater's alert banner. */
html[data-toast-pos="top-full"] .hive-toasts,
html[data-toast-pos="bottom-full"] .hive-toasts {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: min(calc(100vw - 2 * var(--space-4)), var(--page-max-width, 1200px));
  max-width: none;
}
html[data-toast-pos="top-full"] .hive-toasts { top: calc(var(--topbar-h, 0px) + var(--space-3)); bottom: auto; }
/* Push (flow) mode: the container sits in the page flow, in the host's toasts-top / toasts-bottom slot (first / last child of the page wrapper). */
html[data-toast-pos$="-full"] .hive-toasts {
  position: static;
  transform: none;
  width: auto;
  max-width: none;
  margin: var(--space-2) 0;
  padding: 0;
}
html[data-toast-pos$="-full"] .hive-toasts:empty { display: none; margin: 0; }
.hive-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--info);
  border-radius: var(--radius);
  background: var(--info-bg);
  color: var(--info);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: var(--lh-base);
  animation: hive-toast-in calc(var(--toast-fade-ms) * 1ms) ease-out;
  transition: opacity calc(var(--toast-fade-ms) * 1ms) ease;
}
.hive-toast.is-leaving { opacity: 0; }   /* host adds this, then removes the element after --toast-fade-ms */
@keyframes hive-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.hive-toast--success { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.hive-toast--warning { border-color: var(--warning); background: var(--warning-bg); color: var(--warning); }
.hive-toast--danger { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.hive-toast__close {
  margin-left: auto;
  padding: 0 var(--space-1);
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  font-size: var(--fs-lead);
  line-height: 1;
  cursor: pointer;
}
.hive-toast__close:hover { opacity: 1; }

/* Form errors (contract 1.4). A field that needs fixing gets aria-invalid="true" (HiveToast.invalid
   sets it), a danger border and ring, and an inline .hive-field-error message under it. Wrap a
   label + control in .hive-field to also colour the label. */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], .hive-select[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
  background: var(--danger-bg);
}
.hive-field-error {
  margin-top: var(--space-1);
  color: var(--danger);
  font-size: var(--fs-small);
  line-height: var(--lh-base);
}
.hive-field--invalid > label { color: var(--danger); }
