/* =========================================================================
   1. Tokens
   ========================================================================= */

:root {
  /* Color — surfaces */
  --bg: #f4f6f6;
  --surface: #fff;
  --surface-1: #fafafa;
  --surface-cream: linear-gradient(180deg, var(--success-bg) 0%, var(--surface-1) 100%);
  --surface-cream-hover: #f5f2e8;

  /* Color — text */
  --text: #212121;
  --text-muted: #4e4e4e;
  --text-on-accent: var(--bg);

  /* Color — borders */
  --border: #d2dadc;
  --border-cream: #c3a778;

  /* Color — accents */
  --accent: #a57c35;
  --accent-strong: #8f6c2d;
  --accent-light: #b49054;
  --accent-warn: #a86b16;

  /* Color — feedback */
  --danger: #9f3a22;
  --danger-bg: #fff8f6;
  --danger-text-strong: #7a1e0a;
  --danger-surface: #f5d9d3;
  --success: #2a7a3b;
  --success-bg: #f9f7f0;
  --warning-border: #d4a44c;
  --warning-text: #7a5500;

  /* Spacing scale (8-pt) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;

  /* Radii */
  --radius-sm: 12px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --radius-circle: 50%;

  /* Type */
  --font-sans: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
  --font-serif: 'Droid Serif', Georgia, serif;
  --font-display: 'Capri Serif', 'Droid Serif', Georgia, serif;

  /* Effects */
  --shadow-panel: 0 22px 50px rgb(26 30 34 / 0.08);
  --shadow-button: 0 10px 24px color-mix(in srgb, var(--accent) 24%, transparent);
  --focus-ring: 2px solid color-mix(in srgb, var(--accent) 34%, transparent);

  /* Motion */
  --transition-fast: 140ms ease;

  /* Breakpoints */
  --bp-sm: 40em;
}

/* =========================================================================
   2. Reset
   ========================================================================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 12%, transparent), transparent 34%),
    radial-gradient(circle at bottom right, color-mix(in srgb, var(--border) 50%, transparent), transparent 36%),
    linear-gradient(168deg, var(--surface-1) 0%, var(--bg) 58%, var(--bg) 100%);
  padding: var(--space-7) var(--space-4);
}

/* =========================================================================
   3. Base elements
   ========================================================================= */

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 4.3rem;
  line-height: 1.02;
  font-weight: 700;
}

h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
}

label {
  display: grid;
  gap: var(--space-2);
  font-size: 0.95rem;
}

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

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1);
  color: var(--text);
}

textarea {
  min-height: 180px;
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 28%, transparent);
  outline-offset: 1px;
  border-color: var(--border-cream);
}

button {
  border: 0;
  border-radius: var(--radius-pill);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  background: linear-gradient(145deg, var(--accent-light) 0%, var(--accent) 100%);
  color: var(--text-on-accent);
  font-weight: 700;
  transition: background var(--transition-fast), filter var(--transition-fast);
  box-shadow: var(--shadow-button);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

button:hover {
  filter: brightness(1.1);
}

button:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

button:active:not(:disabled) {
  filter: brightness(0.96);
}

/* =========================================================================
   4. Layout
   ========================================================================= */

.shell {
  width: 100%;
  flex: 1 0 auto;
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  gap: var(--space-5);
  align-content: start;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  margin-top: var(--space-4);
}

.site-footer {
  width: 100%;
  max-width: 880px;
  margin: 28px auto 0;
  padding: 18px var(--space-2) var(--space-1);
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
}

.site-footer small {
  font-size: 0.82rem;
  letter-spacing: 0.01em;
}

/* =========================================================================
   5. Components
   ========================================================================= */

/* Hero -------------------------------------------------------------------- */

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: 28px;
  height: auto;
  display: grid;
  gap: 10px;
  align-content: start;
}

.hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.eyebrow {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.hero p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

/* Panel ------------------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: var(--space-6);
  display: grid;
  gap: var(--space-4);
}

.panel p,
.panel li {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.panel ul {
  margin: 0;
  padding-left: 18px;
}

.panel ol {
  margin-top: -8px;
}

/* Login gate -------------------------------------------------------------- */

.login-gate {
  display: grid;
  gap: 10px;
  padding: var(--space-3) 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.login-gate__title {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

/* Create form ------------------------------------------------------------- */

.create-fields {
  display: grid;
  gap: var(--space-4);
}

.create-another-button {
  margin-top: 80px;
}

/* Note box ---------------------------------------------------------------- */

.note-box {
  padding: 14px var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.note-box--action {
  display: grid;
  place-items: center;
  min-height: 220px;
  text-align: center;
  font-weight: 700;
  color: var(--accent-strong);
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border-cream);
  background: var(--surface-cream);
}

.note-box--action:hover {
  background: var(--surface-cream-hover);
}

.note-box--action:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.note-box--action:active {
  background: var(--surface-cream-hover);
  filter: brightness(0.98);
}

.note-box--content {
  display: block;
  min-height: 0;
  text-align: left;
  font-weight: 500;
  color: var(--text);
  cursor: text;
  user-select: text;
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}

.note-box--error {
  display: grid;
  place-items: center;
  min-height: 220px;
  text-align: center;
  font-weight: 700;
  color: var(--danger-text-strong);
  background: var(--danger-surface);
  border: 2px solid color-mix(in srgb, var(--danger) 55%, transparent);
}

/* Link box & copy-link field --------------------------------------------- */

.link-box {
  padding: 14px var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
  display: grid;
  gap: var(--space-3);
}

.share-link-hint {
  margin: 6px 2px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.copy-link-field {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-3) 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-cream);
  background: var(--surface-cream);
  color: var(--text);
  font-weight: 400;
  box-shadow: none;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.copy-link-field:hover {
  background: var(--surface-cream-hover);
  filter: none;
}

.copy-link-field__url {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-sans);
}

.copy-link-field__label {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-strong);
}

.copy-link-field[data-state="copied"] .copy-link-field__label {
  color: var(--success);
}

.copy-link-field[data-state="error"] .copy-link-field__label {
  color: var(--danger);
}

/* Burned warning ---------------------------------------------------------- */

.burned-warning {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--success-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  font-size: 0.92rem;
  line-height: 1.5;
  margin-bottom: var(--space-2);
}

/* Status ------------------------------------------------------------------ */

.status {
  padding: 14px var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
}

.status[data-tone="error"] {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
  background: var(--danger-bg);
}

.status[data-tone="success"] {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  background: var(--success-bg);
}

/* Field hint -------------------------------------------------------------- */

.field-hint {
  justify-self: end;
  font-size: 0.82rem;
  color: rgb(95 103 95 / 0.9);
}

.field-hint[data-tone="warn"] {
  color: var(--accent-warn);
}

.field-hint[data-tone="error"] {
  color: var(--danger);
  font-weight: 600;
}

/* Spinner ----------------------------------------------------------------- */

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-circle);
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

.note-box .spinner {
  width: 1.6em;
  height: 1.6em;
  margin-right: 0;
  margin-bottom: var(--space-2);
}

/* Compat error banner ---------------------------------------------------- */

#compat-error-banner {
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--text);
  margin-bottom: var(--space-6);
  padding: var(--space-5) var(--space-6);
}

.compat-error-title {
  color: var(--danger);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 var(--space-2);
}

.compat-error-intro {
  margin: 0 0 var(--space-3);
}

.compat-error-list {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
}

.compat-error-list li {
  margin-bottom: 6px;
}

.compat-error-suggestion {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

/* =========================================================================
   6. Utilities
   ========================================================================= */

.hidden {
  display: none !important;
}

.button--ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  filter: none;
}

.button--ghost:hover {
  background: var(--bg);
  filter: none;
}

/* =========================================================================
   7. Responsive
   ========================================================================= */

@media (prefers-reduced-motion: no-preference) {
  @keyframes note-reveal {
    from {
      opacity: 0;
      transform: translateY(4px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .note-box--content {
    animation: note-reveal 200ms ease forwards;
  }
}

@media (max-width: 40em) {
  body {
    padding: 18px var(--space-3);
  }

  .site-footer {
    margin-top: 22px;
    padding-top: 14px;
  }

  .panel {
    border-radius: var(--radius-lg);
    padding: var(--space-5);
  }
}
