/* ============================================================
   THE HUMAN CO. — DESIGN SYSTEM
   Shared CSS for all Gumroad digital products.
   Adapted from Co.LLab UI Style Guide.
   ============================================================ */

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Core Palette */
  --color-canvas:        #EAEAEA;
  --color-surface:       #FFFFFF;
  --color-text:          #101216;
  --color-structure:     #3A4252;
  --color-action:        #FF2E63;

  /* Status / Functional Colors */
  --color-status-progress: #6C5CE7;
  --color-status-complete: #2EC4B6;

  /* Typography */
  --font-heading: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-body:    'Work Sans', sans-serif;

  /* Spacing Scale — 8px base */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;
  --space-7:  48px;
  --space-8:  64px;

  /* Borders */
  --border-default: 1px solid var(--color-structure);
  --border-focus:   2px solid var(--color-text);
  --border-error:   1px solid var(--color-action);
  --radius:         4px;

  /* Card */
  --card-border: 1px solid var(--color-structure);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: var(--color-text);
  text-decoration: underline;
}

a:hover {
  opacity: 0.85;
}

ul, ol {
  list-style: none;
}

/* ============================================================
   TYPOGRAPHY CLASSES
   ============================================================ */
.type-h1 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
  color: var(--color-text);
}

.type-h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
  color: var(--color-text);
}

.type-h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  color: var(--color-text);
}

.type-h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  color: var(--color-text);
}

.type-body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  max-width: 560px;
}

.type-small {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-structure);
}

.type-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ============================================================
   PRODUCT SHELL — single-page layout (no sidebar)
   ============================================================ */
.product-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   PRODUCT HEADER — dark top bar
   ============================================================ */
.product-header {
  background: var(--color-text);
  color: #fff;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.product-header-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: #fff;
}

.product-header-brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.product-header-brand span {
  color: var(--color-action);
}

/* ============================================================
   PRODUCT CANVAS — main content area
   ============================================================ */
.product-canvas {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

@media (min-width: 640px) {
  .product-canvas {
    padding: var(--space-7) var(--space-5);
  }
}

/* ============================================================
   PRODUCT FOOTER — bottom bar with branding
   ============================================================ */
.product-footer {
  background: var(--color-text);
  color: rgba(255, 255, 255, 0.5);
  padding: var(--space-4) var(--space-5);
  text-align: center;
  font-family: var(--font-body);
  font-size: 12px;
  flex-shrink: 0;
}

.product-footer a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: underline;
}

.product-footer a:hover {
  color: #fff;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  transition: opacity 0.15s;
  text-decoration: none;
  border: none;
  background: none;
  line-height: 1.4;
}

.btn:hover {
  opacity: 0.85;
}

.btn:focus-visible {
  outline: var(--border-focus);
  outline-offset: 2px;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-action);
  color: #fff;
  border: none;
}

.btn-secondary {
  background: transparent;
  color: var(--color-structure);
  border: 2px solid var(--color-structure);
}

.btn-tertiary {
  background: transparent;
  color: var(--color-text);
  border: none;
  text-decoration: underline;
  padding: 10px 0;
}

.btn-danger {
  background: transparent;
  color: var(--color-action);
  border: 2px solid var(--color-action);
}

/* Button loading state */
.btn.is-loading {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-primary.is-loading::after {
  border-color: #fff;
  border-right-color: transparent;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.form-label .required-indicator {
  color: var(--color-action);
  margin-left: 2px;
}

.form-input,
.form-select,
textarea.form-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-structure);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
  transition: border 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
textarea.form-input:focus {
  border: var(--border-focus);
}

.form-input::placeholder,
textarea.form-input::placeholder {
  color: #9ca3af;
}

.form-input.error,
.form-select.error,
textarea.form-input.error {
  border-color: var(--color-action);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* Select */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%233A4252' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-hint {
  font-size: 12px;
  color: var(--color-structure);
  margin-top: var(--space-1);
  line-height: 1.4;
}

.form-hint.error {
  color: var(--color-action);
}

.form-error-message {
  font-size: 12px;
  color: var(--color-action);
  margin-top: var(--space-1);
  line-height: 1.4;
}

/* Radio buttons */
.radio-group,
.checkbox-group {
  margin-bottom: var(--space-5);
}

.radio-group-label,
.checkbox-group-label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.radio-option,
.checkbox-option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

.radio-option input[type="radio"],
.checkbox-option input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--color-action);
  cursor: pointer;
}

.radio-option input[type="radio"]:focus-visible,
.checkbox-option input[type="checkbox"]:focus-visible {
  outline: var(--border-focus);
  outline-offset: 2px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-surface);
  border: var(--card-border);
  padding: var(--space-5);
}

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

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

.card-tag {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-structure);
  margin-bottom: var(--space-3);
}

.card-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: var(--space-2);
}

.card-body {
  font-size: 13px;
  color: var(--color-structure);
  line-height: 1.5;
  margin-bottom: var(--space-4);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-4);
  border-top: var(--border-default);
}

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius);
  display: inline-block;
}

.badge-draft {
  background: var(--color-canvas);
  color: var(--color-structure);
  border: 1px solid var(--color-structure);
}

.badge-progress {
  background: rgba(108, 92, 231, 0.12);
  color: var(--color-status-progress);
  border: 1px solid var(--color-status-progress);
}

.badge-complete {
  background: rgba(46, 196, 182, 0.12);
  color: var(--color-status-complete);
  border: 1px solid var(--color-status-complete);
}

.badge-action {
  background: rgba(255, 46, 99, 0.1);
  color: var(--color-action);
  border: 1px solid var(--color-action);
}

/* ============================================================
   OUTPUT / RESULTS SECTION
   ============================================================ */
.output-section {
  background: var(--color-surface);
  border: var(--card-border);
  padding: var(--space-5);
  margin-top: var(--space-5);
}

.output-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: var(--border-default);
}

.output-section-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-structure);
}

.output-section-body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
}

.output-section-body h3 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
}

.output-section-body h3:first-child {
  margin-top: 0;
}

.output-section-body p {
  margin-bottom: var(--space-3);
}

.output-section-body ul,
.output-section-body ol {
  margin-bottom: var(--space-3);
  padding-left: var(--space-5);
}

.output-section-body ul {
  list-style: disc;
}

.output-section-body ol {
  list-style: decimal;
}

.output-section-body li {
  margin-bottom: var(--space-1);
}

/* ============================================================
   LOADING SPINNER (CSS-only)
   ============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-structure);
  border-top-color: var(--color-action);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.loading-spinner-small {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-7) 0;
}

.loading-container .loading-text {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-structure);
}

/* ============================================================
   ACCESS CODE INPUT
   ============================================================ */
.access-code-section {
  background: var(--color-surface);
  border: var(--card-border);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.access-code-section .form-label {
  margin-bottom: var(--space-2);
}

.access-code-input-row {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.access-code-input-row .form-input {
  flex: 1;
  font-family: monospace;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.access-code-input-row .btn {
  flex-shrink: 0;
}

.access-code-status {
  margin-top: var(--space-3);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.access-code-status.valid {
  color: var(--color-status-complete);
}

.access-code-status.invalid {
  color: var(--color-action);
}

/* ============================================================
   REMAINING GENERATIONS COUNTER
   ============================================================ */
.generations-counter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-structure);
  padding: var(--space-2) var(--space-3);
  border: var(--border-default);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.generations-counter-number {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  color: var(--color-text);
  letter-spacing: 0;
  text-transform: none;
}

.generations-counter.low .generations-counter-number {
  color: var(--color-action);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }

/* ============================================================
   RESPONSIVE — breakpoint at 640px
   ============================================================ */
@media (max-width: 639px) {
  .type-h1 {
    font-size: 26px;
  }

  .type-h2 {
    font-size: 19px;
  }

  .product-header {
    padding: var(--space-3) var(--space-4);
  }

  .product-header-name {
    font-size: 13px;
  }

  .access-code-input-row {
    flex-direction: column;
  }

  .access-code-input-row .btn {
    width: 100%;
  }

  .btn {
    font-size: 13px;
    padding: 8px 16px;
  }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  .product-header,
  .product-footer,
  .access-code-section,
  .generations-counter,
  .btn,
  .loading-spinner,
  .loading-container {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }

  .product-shell {
    min-height: auto;
  }

  .product-canvas {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .output-section {
    border: 1px solid #ccc;
    padding: 12pt;
    break-inside: avoid;
  }

  .card {
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  a {
    text-decoration: none;
    color: #000;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #666;
  }
}
