/* KiwiHacks design tokens and the handful of components that carry the
 * identity directly.
 *
 * The bulk of the rebrand happens in themes.css, which re-points the semantic
 * palette and the Tailwind --color-* tokens. This file adds the pieces that
 * need explicit opting into: the leaf-and-dashed primary action, the craft
 * card, the status chip, and the sky focus ring.
 *
 * Per the design language, use the expressive treatments on participant-facing
 * and public surfaces. Admin tables, scan history and event forms stay calm. */

:root {
  /* Core brand */
  --kh-paper: #eae6e2;
  --kh-ink: #132f1e;
  --kh-forest: #2e522b;
  --kh-leaf: #76b070;
  --kh-leaf-hover: #88bc82;
  --kh-leaf-soft: rgba(118, 176, 112, 0.15);
  --kh-leaf-panel: rgba(118, 176, 112, 0.3);
  --kh-sky: #36c6fb;
  --kh-sky-soft: #baedff;
  --kh-sky-wash: rgba(145, 226, 255, 0.81);
  --kh-cork: #a58f75;

  /* Product neutrals */
  --kh-surface: #f7f4f0;
  --kh-surface-strong: #ffffff;
  --kh-border: rgba(19, 47, 30, 0.22);
  --kh-muted: #607067;
  --kh-disabled: #c9cec9;

  /* Semantic */
  --kh-success-surface: #ddf2df;
  --kh-success-ink: #205b2a;
  --kh-info-surface: #ddf4fc;
  --kh-info-ink: #155a72;
  --kh-warning-surface: #fff0c7;
  --kh-warning-ink: #6a4b00;
  --kh-danger-surface: #f9ddda;
  --kh-danger-ink: #8a241e;

  /* Typography. Faces are loaded in the layout; the stacks fall back to system
   * fonts so nothing depends on the network. */
  --kh-font-body: "Figtree", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --kh-font-display: "ABeeZee", "Figtree", ui-sans-serif, system-ui, sans-serif;
  --kh-font-mono: "Source Code Pro", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Geometry */
  --kh-radius-sm: 8px;
  --kh-radius-md: 12px;
  --kh-radius-lg: 15px;
  --kh-radius-xl: 24px;

  /* Shadows */
  --kh-shadow-xs: 0 1px 2px rgba(19, 47, 30, 0.14);
  --kh-shadow-sm: 0 2px 4px rgba(19, 47, 30, 0.18);
  --kh-shadow-md: 0 8px 18px rgba(19, 47, 30, 0.14);
  --kh-shadow-lift: 0 6px 0 rgba(19, 47, 30, 0.12);

  --kh-control-min-size: 44px;
  --kh-motion-fast: 150ms;
  --kh-motion-normal: 240ms;
}

body {
  font-family: var(--kh-font-body);
}

h1, h2, h3 {
  font-family: var(--kh-font-display);
}

/* Obvious against paper, green, blue and white alike. */
:focus-visible {
  outline: 3px solid var(--kh-sky);
  outline-offset: 3px;
}

.kh-display {
  font-family: var(--kh-font-display);
  font-weight: 400;
}

.kh-mono {
  font-family: var(--kh-font-mono);
  font-variant-numeric: tabular-nums;
}

.kh-button {
  min-height: var(--kh-control-min-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--kh-radius-lg);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--kh-motion-normal) ease,
    box-shadow var(--kh-motion-normal) ease,
    transform var(--kh-motion-fast) ease;
}

/* Leaf fill with ink text — the contrast that lets leaf be used at all. */
.kh-button--primary {
  color: var(--kh-ink);
  background: var(--kh-leaf);
  border: 1.5px dashed var(--kh-ink);
}

.kh-button--primary:hover {
  background: var(--kh-leaf-hover);
  box-shadow: var(--kh-shadow-lift);
  transform: translateY(-2px);
}

.kh-button--secondary {
  color: var(--kh-ink);
  background: var(--kh-sky-wash);
  border: 1.5px solid var(--kh-ink);
}

.kh-button--secondary:hover {
  background: var(--kh-sky-soft);
  box-shadow: var(--kh-shadow-sm);
  transform: translateY(-1px);
}

/* Solid border, never the playful dashed treatment. */
.kh-button--danger {
  color: var(--kh-danger-ink);
  background: var(--kh-danger-surface);
  border: 1.5px solid var(--kh-danger-ink);
}

.kh-button:disabled,
.kh-button[aria-disabled="true"] {
  color: var(--kh-muted);
  background: var(--kh-disabled);
  border-color: var(--kh-border);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.kh-card {
  background: var(--kh-surface-strong);
  border: 1px solid var(--kh-border);
  border-radius: var(--kh-radius-lg);
  box-shadow: var(--kh-shadow-xs);
}

.kh-card--promo {
  background: var(--kh-leaf-soft);
  border: 2px dashed var(--kh-ink);
}

.kh-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.75rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1;
}

.kh-status--success { color: var(--kh-success-ink); background: var(--kh-success-surface); }
.kh-status--info    { color: var(--kh-info-ink);    background: var(--kh-info-surface); }
.kh-status--warning { color: var(--kh-warning-ink); background: var(--kh-warning-surface); }
.kh-status--danger  { color: var(--kh-danger-ink);  background: var(--kh-danger-surface); }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Organiser-authored Markdown — event rules, resource notes, announcements,
 * sponsor blurbs. Tailwind's preflight strips heading and list styling, so
 * rendered Markdown needs its own scoped rules. Colours come from the theme
 * tokens rather than the brand ones so the blocks read correctly on dark
 * themes too. */
.kh-prose {
  color: var(--text, var(--kh-ink));
  font-size: 1rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.kh-prose > * + * {
  margin-top: 0.85rem;
}

.kh-prose h1,
.kh-prose h2,
.kh-prose h3,
.kh-prose h4 {
  font-family: var(--kh-font-display);
  color: var(--text-strong, var(--kh-ink));
  font-weight: 700;
  line-height: 1.25;
}

.kh-prose h1 { font-size: 1.4rem; }
.kh-prose h2 { font-size: 1.2rem; }
.kh-prose h3 { font-size: 1.05rem; }
.kh-prose h4 { font-size: 1rem; }

.kh-prose > h1 + *,
.kh-prose > h2 + *,
.kh-prose > h3 + *,
.kh-prose > h4 + * {
  margin-top: 0.4rem;
}

.kh-prose ul,
.kh-prose ol {
  padding-left: 1.4rem;
}

.kh-prose ul { list-style: disc; }
.kh-prose ol { list-style: decimal; }
.kh-prose li + li { margin-top: 0.3rem; }
.kh-prose li > ul,
.kh-prose li > ol { margin-top: 0.3rem; }

.kh-prose a {
  color: var(--kh-info-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.kh-prose a:hover { text-decoration-thickness: 2px; }

.kh-prose strong { font-weight: 700; }
.kh-prose em { font-style: italic; }

.kh-prose code {
  font-family: var(--kh-font-mono);
  font-size: 0.9em;
  padding: 0.1rem 0.35rem;
  border-radius: var(--kh-radius-sm);
  background: var(--bg-elev-2, rgba(19, 47, 30, 0.07));
}

.kh-prose pre {
  font-family: var(--kh-font-mono);
  font-size: 0.875rem;
  padding: 0.85rem 1rem;
  border-radius: var(--kh-radius-md);
  background: var(--bg-elev-2, rgba(19, 47, 30, 0.07));
  overflow-x: auto;
}

.kh-prose pre code {
  padding: 0;
  background: none;
}

.kh-prose blockquote {
  padding-left: 0.9rem;
  border-left: 3px solid var(--kh-leaf);
  color: var(--text-soft, var(--kh-muted));
}

.kh-prose hr {
  border: 0;
  border-top: 1px dashed var(--border-card, var(--kh-border));
}

.kh-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  display: block;
  overflow-x: auto;
}

.kh-prose th,
.kh-prose td {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border-card, var(--kh-border));
  text-align: left;
}

.kh-prose th {
  font-weight: 700;
  background: var(--bg-elev-2, rgba(19, 47, 30, 0.05));
}

.kh-prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--kh-radius-md);
}

/* The /docs manual: long reference pages with many headings and wide
 * Actions tables. Sections get clear breaks, headings leave room under a
 * jumped-to anchor, and tables scroll sideways rather than squeezing their
 * cells until words split mid-letter. */
.kh-docs > h2 {
  margin-top: 2.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-card, var(--kh-border));
}

.kh-docs > h3 { margin-top: 1.75rem; }

.kh-docs h2,
.kh-docs h3 { scroll-margin-top: 5rem; } /* clears the sticky docs header */

.kh-docs table {
  font-size: 0.875rem;
  overflow-wrap: normal;
}

.kh-docs th,
.kh-docs td {
  min-width: 7rem;
  vertical-align: top;
}

.kh-docs th:nth-child(3),
.kh-docs td:nth-child(3) { min-width: 14rem; }

.kh-docs th:nth-child(4),
.kh-docs td:nth-child(4) { min-width: 11rem; }

/* Paths wrap at the <wbr> DocsHelper adds after each "/" and "_"; anything
 * still too long for its cell may break wherever it must. */
.kh-docs td code { overflow-wrap: anywhere; }

/* Compact variant for list rows and cards. */
.kh-prose--tight {
  font-size: 0.9375rem;
  line-height: 1.55;
}

.kh-prose--tight > * + * {
  margin-top: 0.5rem;
}

/* Horizontally scrolling strip (the Event Hub section nav on a phone). Fades the
 * trailing edge so it is visible that the row continues past the viewport —
 * a scroll affordance, not decoration. The fade disappears once scrolled to the
 * end, and is skipped entirely where mask-image is unsupported. */
@supports (mask-image: linear-gradient(#000, #000)) or (-webkit-mask-image: linear-gradient(#000, #000)) {
  .kh-scroll-x {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent 100%);
    mask-image: linear-gradient(to right, #000 calc(100% - 2rem), transparent 100%);
  }

  /* Nothing left to hint at once the strip is scrolled to its end; the
     scroll-fade Stimulus controller sets this. */
  .kh-scroll-x[data-scrolled-to-end="true"] {
    -webkit-mask-image: none;
    mask-image: none;
  }
}

/* Scrollbars on this strip are noise on desktop and absent on touch anyway. */
.kh-scroll-x { scrollbar-width: none; }
.kh-scroll-x::-webkit-scrollbar { display: none; }

/* The Event Hub's help action. It uses the primary button recipe, plus a little
 * extra weight: this is the control an attendee may need while something is
 * actually going wrong, and the design language is explicit that such a control
 * must not be pale or quiet. */
.kh-help-action {
  box-shadow: var(--kh-shadow-sm);
}

/* Already on the help section — hold the pressed state so the button reads as
 * "you are here" rather than inviting another tap. */
.kh-help-action.is-active {
  background: var(--kh-leaf-hover);
  box-shadow: none;
  transform: none;
}

/* An open request. Colour alone never carries this: the button's aria-label
 * says so, and the banner underneath states it in words. */
.kh-help-action__pip {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--kh-danger-ink);
  box-shadow: 0 0 0 2px var(--kh-leaf);
  animation: kh-help-pip 2s ease-in-out infinite;
}

@keyframes kh-help-pip {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .kh-help-action__pip { animation: none; }
}
