/*
 * Pafi Design System
 *
 * Dark-mode design system built on Josh W. Comeau's CSS Reset.
 * Styles semantic HTML directly — no CSS classes needed.
 *
 * Contents:
 *   1. Reset
 *   2. Design Tokens
 *   3. Global
 *   4. Typography
 *   5. Layout
 *   6. Navigation
 *   7. Forms
 *   8. Feedback
 *   9. Lists
 */


/* ==========================================================================
   1. RESET — Josh's Custom CSS Reset
   https://www.joshwcomeau.com/css/custom-css-reset/
   ========================================================================== */

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

*:not(dialog) {
  margin: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

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

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

p {
  text-wrap: pretty;
}

h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
}


/* ==========================================================================
   2. DESIGN TOKENS
   ========================================================================== */

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;

  /* Surfaces */
  --surface-0: #09090b;
  --surface-1: #18181b;
  --surface-2: #27272a;
  --surface-3: #3f3f46;

  /* Text */
  --text-0: #fafafa;
  --text-1: #a1a1aa;
  --text-2: #71717a;

  /* Accent — Indigo */
  --accent: #818cf8;
  --accent-hover: #a5b4fc;

  /* Feedback */
  --success: #4ade80;
  --success-subtle: #052e16;
  --danger: #f87171;
  --danger-subtle: #450a0a;

  /* Sizing */
  --content-width: 56rem;
  --narrow-width: 24rem;
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
}


/* ==========================================================================
   3. GLOBAL
   ========================================================================== */

html {
  color-scheme: dark;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ==========================================================================
   4. TYPOGRAPHY
   ========================================================================== */

body {
  font-family: var(--font-sans);
  background: var(--surface-0);
  color: var(--text-0);
}

h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; color: var(--text-1); }
h3 { font-size: 1.125rem; font-weight: 600; color: var(--text-1); }

a {
  color: var(--accent);
  text-decoration: none;

  &:hover {
    color: var(--accent-hover);
    text-decoration: underline;
  }
}

small {
  font-size: 0.875rem;
  color: var(--text-2);
}

hr {
  border: none;
  border-top: 1px solid var(--surface-3);
  margin-block: 1.5rem;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface-2);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
}


/* ==========================================================================
   5. LAYOUT
   ========================================================================== */

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Authenticated pages — main fills remaining space */
main {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding: 2rem 1.5rem;
}

/* Flow spacing within main content */
main > * + * {
  margin-block-start: 1.5rem;
}

/* Guest pages (no header) — center everything */
body:not(:has(> header)) > main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  gap: 1rem;
}

body:not(:has(> header)) > main > * {
  width: 100%;
  max-width: var(--narrow-width);
}

/* Article — card container */
article {
  background: var(--surface-1);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: var(--narrow-width);
  margin-inline: auto;
}

article > header {
  text-align: center;
}

article > * + * {
  margin-block-start: 1rem;
}

article > footer {
  margin-block-start: 1.5rem;
  padding-block-start: 1rem;
  border-top: 1px solid var(--surface-2);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-2);
}

/* Sections */
section {
  margin-block-start: 2rem;
}

section > * + * {
  margin-block-start: 0.75rem;
}

section > p {
  color: var(--text-1);
}


/* ==========================================================================
   6. NAVIGATION
   ========================================================================== */

header {
  border-bottom: 1px solid var(--surface-2);
  background: var(--surface-1);
}

header > nav {
  max-width: var(--content-width);
  margin-inline: auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Logo link */
header nav > a {
  color: var(--text-0);
  font-weight: 600;
  font-size: 1.125rem;

  &:hover {
    color: var(--text-0);
    text-decoration: none;
  }
}

/* button_to generates a <form>; make it invisible to layout */
nav form {
  display: contents;
}


/* ==========================================================================
   7. FORMS
   ========================================================================== */

form label {
  display: block;
  margin-block-start: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-1);
}

form label:first-child {
  margin-block-start: 0;
}

form input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]),
form select,
form textarea {
  display: block;
  width: 100%;
  margin-block-start: 0.375rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-sm);
  color: var(--text-0);

  &::placeholder {
    color: var(--text-2);
  }

  &:focus-visible {
    border-color: var(--accent);
    outline-offset: -1px;
  }
}

form select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-inline-end: 2.5rem;
}

/* Constrain forms inside wider layouts */
section > form {
  max-width: var(--narrow-width);
}

/* Buttons — shared base */
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

/* Primary — form submit */
input[type="submit"] {
  margin-block-start: 1.5rem;
  width: 100%;
  background: var(--accent);
  color: #fff;

  &:hover {
    background: var(--accent-hover);
    color: #1e1b4b;
  }
}

/* Ghost — standalone buttons (nav, actions) */
button {
  background: transparent;
  color: var(--text-1);
  border-color: var(--surface-3);

  &:hover {
    background: var(--surface-2);
    color: var(--text-0);
  }
}


/* ==========================================================================
   8. FEEDBACK — Flash Messages
   ========================================================================== */

[role="alert"] {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}

[role="status"] {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background: var(--success-subtle);
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 25%, transparent);
}


/* ==========================================================================
   9. LISTS
   ========================================================================== */

ul, ol {
  padding-inline-start: 0;
  list-style: none;
}

ul > li,
ol > li {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--surface-2);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

ul > li:last-child,
ol > li:last-child {
  border-bottom: none;
}
