/* ============================================================
   Trex Pi - trexpi.css  (v2.0 · July 2026)
   The complete web implementation of the Trex Pi style book.
   Two faces (Verdana/Tahoma, system), six sizes, one focus ring.
   Usage: <link rel="stylesheet" href="trexpi.css">
   ============================================================ */

:root {
  /* Greens */
  --tp-green-50:  #EAF9F0;
  --tp-green-100: #A8E6CF;
  --tp-green-200: #7DDCAE;
  --tp-green-300: #5FD193;
  --tp-green-400: #45C77F;
  --tp-green-500: #2FBF71;   /* primary */
  --tp-green-600: #1FA868;
  --tp-green-700: #187C50;   /* text-safe green */
  /* Neutrals */
  --tp-white:  #FFFFFF;
  --tp-mist:   #F3F7F5;
  --tp-border: #E2EEE7;
  --tp-steel:  #7E9187;
  --tp-body:   #51635A;
  --tp-ink:    #243029;
  /* Functional */
  --tp-error:        #C94040;
  --tp-error-tint:   #FBEDED;
  --tp-warning:      #9A6110;
  --tp-warning-tint: #FDF3E3;
  --tp-success:      var(--tp-green-700);
  --tp-success-tint: var(--tp-green-50);
  /* Type */
  --tp-font-head: Verdana, Geneva, "DejaVu Sans", sans-serif;
  --tp-font-body: Tahoma, Verdana, sans-serif;
  /* The six sizes (web) */
  --tp-display: 44px;
  --tp-title:   28px;
  --tp-heading: 20px;
  --tp-text:    15px;
  --tp-small:   13px;
  --tp-caption: 11px;
  /* Space (six steps) */
  --tp-s1: 8px;  --tp-s2: 16px; --tp-s3: 24px;
  --tp-s4: 32px; --tp-s5: 48px; --tp-s6: 64px;
  /* Shape */
  --tp-radius: 8px;        /* controls */
  --tp-radius-lg: 12px;    /* cards, modals */
  --tp-shadow-raised:  0 1px 2px rgba(36,48,41,.06);
  --tp-shadow-overlay: 0 12px 32px rgba(36,48,41,.14);
  --tp-ring: 0 0 0 3px rgba(47,191,113,.35);
  --tp-ring-error: 0 0 0 3px rgba(201,64,64,.2);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--tp-font-body);
  font-size: var(--tp-text);
  line-height: 1.6;
  color: var(--tp-body);
  background: var(--tp-white);
}
.tp-container { max-width: 1200px; margin: 0 auto; padding: 0 var(--tp-s3); }

/* ---------- Typography ---------- */
.tp-display, .tp-title, .tp-heading {
  font-family: var(--tp-font-head);
  font-weight: 700;
  color: var(--tp-ink);
  margin: 0;
}
.tp-display { font-size: var(--tp-display); line-height: 1.15; letter-spacing: -0.01em; }
.tp-title   { font-size: var(--tp-title);   line-height: 1.25; letter-spacing: -0.01em; }
.tp-heading { font-size: var(--tp-heading); line-height: 1.35; }
.tp-text    { font-size: var(--tp-text);    line-height: 1.6; margin: 0; }
.tp-small   { font-size: var(--tp-small);   line-height: 1.5; }
.tp-caption { font-size: var(--tp-caption); line-height: 1.45; color: var(--tp-steel); }
.tp-kicker {
  font-family: var(--tp-font-head); font-weight: 700;
  font-size: var(--tp-caption); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--tp-green-700);
}
strong, b { color: var(--tp-ink); }

/* Links */
a, .tp-link {
  color: var(--tp-green-700);
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: 2px;
}
a:hover, .tp-link:hover { color: var(--tp-green-500); }
a:visited:not(.tp-btn), .tp-link:visited { color: var(--tp-body); }
a:active, .tp-link:active { color: var(--tp-ink); }

/* One focus ring, everywhere */
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--tp-ring);
}

/* ---------- Buttons ---------- */
.tp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--tp-s1);
  height: 40px; padding: 0 var(--tp-s2);
  border: none; border-radius: var(--tp-radius);
  font-family: var(--tp-font-head); font-weight: 700; font-size: var(--tp-text);
  color: var(--tp-ink); background: var(--tp-green-500);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.tp-btn:hover  { background: var(--tp-green-400); color: var(--tp-ink); }
.tp-btn:active { transform: translateY(1px); }
.tp-btn:disabled, .tp-btn[aria-disabled="true"] {
  background: var(--tp-mist); color: var(--tp-steel); cursor: not-allowed; transform: none;
}
.tp-btn--secondary {
  background: var(--tp-white); color: var(--tp-green-700);
  border: 1.5px solid var(--tp-green-500);
}
.tp-btn--secondary:hover { background: var(--tp-green-50); color: var(--tp-green-700); }
.tp-btn--secondary:disabled { border-color: var(--tp-border); background: var(--tp-white); }
.tp-btn--tertiary { background: transparent; color: var(--tp-green-700); }
.tp-btn--tertiary:hover { background: var(--tp-green-50); color: var(--tp-green-700); }
.tp-btn--tertiary:disabled { background: transparent; }
.tp-btn--destructive { background: var(--tp-error); color: var(--tp-white); }
.tp-btn--destructive:hover { background: #A83434; color: var(--tp-white); }
.tp-btn--destructive:focus-visible { box-shadow: 0 0 0 3px rgba(201,64,64,.3); }
.tp-btn--sm { height: 32px; padding: 0 12px; font-size: var(--tp-small); }
.tp-btn--lg { height: 48px; padding: 0 20px; }
.tp-btn--icon { width: 40px; padding: 0; }

/* ---------- Forms ---------- */
.tp-field { display: flex; flex-direction: column; gap: 6px; }
.tp-label {
  font-family: var(--tp-font-head); font-weight: 700;
  font-size: var(--tp-small); color: var(--tp-ink);
}
.tp-label .tp-optional { font-family: var(--tp-font-body); font-weight: 400; font-size: var(--tp-caption); color: var(--tp-steel); }
.tp-input, .tp-select, .tp-textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1.5px solid var(--tp-steel); border-radius: var(--tp-radius);
  font-family: var(--tp-font-body); font-size: var(--tp-text); color: var(--tp-ink);
  background: var(--tp-white);
}
.tp-input::placeholder, .tp-textarea::placeholder { color: var(--tp-steel); }
.tp-input:focus, .tp-select:focus, .tp-textarea:focus {
  outline: none; border-color: var(--tp-green-500); box-shadow: var(--tp-ring);
}
.tp-input:disabled, .tp-select:disabled, .tp-textarea:disabled {
  background: var(--tp-mist); border-color: var(--tp-border); color: var(--tp-steel);
}
.tp-textarea { min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.tp-select {
  appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237E9187' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5 12 15.5 18 9.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.tp-help  { font-size: var(--tp-caption); color: var(--tp-steel); }
.tp-error-text { font-size: var(--tp-caption); color: var(--tp-error); }
.tp-field--error .tp-input, .tp-field--error .tp-select, .tp-field--error .tp-textarea {
  border-color: var(--tp-error);
}
.tp-field--error .tp-input:focus { box-shadow: var(--tp-ring-error); }
.tp-search { position: relative; }
.tp-search .tp-input { padding-left: 36px; }
.tp-search::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 16px; height: 16px;
  transform: translateY(-50%);
  background: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237E9187' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6'/%3E%3Cpath d='M15.5 15.5 20 20'/%3E%3C/svg%3E") no-repeat center;
}

/* Checkbox & radio (20px) */
.tp-checkbox, .tp-radio {
  appearance: none; width: 20px; height: 20px; margin: 0; flex-shrink: 0;
  border: 1.5px solid var(--tp-steel); background: var(--tp-white); cursor: pointer;
}
.tp-checkbox { border-radius: 4px; }
.tp-radio    { border-radius: 50%; }
.tp-checkbox:checked {
  background-color: var(--tp-green-600); border-color: var(--tp-green-600);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 12.5 9.5 17.5 19.5 6.5'/%3E%3C/svg%3E");
  background-size: 12px; background-repeat: no-repeat; background-position: center;
}
.tp-checkbox:indeterminate {
  background-color: var(--tp-green-600); border-color: var(--tp-green-600);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='10.75' width='12' height='2.5' rx='1.25' fill='%23FFFFFF'/%3E%3C/svg%3E");
  background-size: 14px; background-repeat: no-repeat; background-position: center;
}
.tp-radio:checked { border: 6px solid var(--tp-green-600); }
.tp-checkbox:disabled, .tp-radio:disabled { background: var(--tp-mist); border-color: var(--tp-border); cursor: not-allowed; }
.tp-choice { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; color: var(--tp-ink); }
.tp-choice:has(:disabled) { color: var(--tp-steel); cursor: not-allowed; }

/* Toggle (40 × 22) */
.tp-toggle {
  appearance: none; width: 40px; height: 22px; margin: 0;
  border: none; border-radius: 999px; background: var(--tp-steel);
  position: relative; cursor: pointer; flex-shrink: 0;
}
.tp-toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--tp-white); transition: left .15s ease-out;
}
.tp-toggle:checked { background: var(--tp-green-600); }
.tp-toggle:checked::after { left: 20px; }
.tp-toggle:disabled { background: var(--tp-border); cursor: not-allowed; }
.tp-toggle:disabled::after { background: var(--tp-mist); }

/* Slider */
.tp-slider { appearance: none; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; }
.tp-slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(var(--tp-green-500), var(--tp-green-500)) 0/var(--tp-fill, 50%) 100% no-repeat, var(--tp-border); }
.tp-slider::-webkit-slider-thumb {
  appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%;
  background: var(--tp-white); border: 1.5px solid var(--tp-green-500); box-shadow: var(--tp-shadow-raised);
}
.tp-slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--tp-border); }
.tp-slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--tp-green-500); }
.tp-slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--tp-white); border: 1.5px solid var(--tp-green-500); }

/* ---------- Navigation ---------- */
.tp-navbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  gap: var(--tp-s3); padding: 0 var(--tp-s3);
  background: var(--tp-white); border-bottom: 1px solid var(--tp-border);
}
.tp-navbar__brand { display: flex; align-items: center; gap: 10px; font-family: var(--tp-font-head); font-weight: 700; font-size: var(--tp-text); color: var(--tp-ink); text-decoration: none; }
.tp-navbar__links { display: flex; align-items: center; gap: 26px; }
.tp-navbar__links a { color: var(--tp-ink); text-decoration: none; }
.tp-navbar__links a:hover { color: var(--tp-green-700); }
.tp-navbar__links a[aria-current="page"] {
  color: var(--tp-green-700); font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--tp-green-500); padding-bottom: 2px;
}
.tp-tabs { display: flex; gap: var(--tp-s3); border-bottom: 1px solid var(--tp-border); }
.tp-tab {
  padding: 8px 2px; border: none; background: none; cursor: pointer;
  font-family: var(--tp-font-body); font-size: var(--tp-text); color: var(--tp-ink);
}
.tp-tab[aria-selected="true"] {
  font-family: var(--tp-font-head); font-weight: 700; color: var(--tp-green-700);
  box-shadow: inset 0 -2px 0 var(--tp-green-500);
}
.tp-tab:disabled { color: var(--tp-steel); cursor: not-allowed; }
.tp-breadcrumb { display: flex; align-items: center; gap: var(--tp-s1); font-size: var(--tp-small); }
.tp-breadcrumb .tp-sep { color: var(--tp-steel); }
.tp-breadcrumb [aria-current="page"] { color: var(--tp-ink); font-weight: 700; text-decoration: none; }
.tp-pagination { display: flex; gap: 6px; }
.tp-page {
  min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px; border: none; border-radius: var(--tp-radius); background: none;
  font-family: var(--tp-font-body); font-size: var(--tp-small); color: var(--tp-ink); cursor: pointer;
}
.tp-page:hover { background: var(--tp-green-50); }
.tp-page[aria-current="page"] { background: var(--tp-green-500); color: var(--tp-ink); font-family: var(--tp-font-head); font-weight: 700; }
.tp-page--nav { border: 1px solid var(--tp-border); }
.tp-footer { background: var(--tp-mist); border-top: 1px solid var(--tp-border); padding: var(--tp-s4) var(--tp-s3); font-size: var(--tp-caption); color: var(--tp-steel); }

/* ---------- Feedback ---------- */
.tp-alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 13px 16px; border-radius: var(--tp-radius);
  font-size: var(--tp-small);
}
.tp-alert--info,  .tp-alert--success { background: var(--tp-success-tint); color: var(--tp-success); }
.tp-alert--warning { background: var(--tp-warning-tint); color: var(--tp-warning); }
.tp-alert--error   { background: var(--tp-error-tint);   color: var(--tp-error); }
.tp-toast {
  display: flex; gap: 10px; align-items: center; width: 340px;
  padding: 14px 16px; background: var(--tp-white);
  border: 1px solid var(--tp-border); border-radius: var(--tp-radius-lg);
  box-shadow: var(--tp-shadow-overlay); font-size: var(--tp-small); color: var(--tp-ink);
}
.tp-modal-overlay {
  position: fixed; inset: 0; background: rgba(36,48,41,.4);
  display: flex; align-items: center; justify-content: center; padding: var(--tp-s3);
}
.tp-modal {
  width: 100%; max-width: 480px; background: var(--tp-white);
  border-radius: var(--tp-radius-lg); box-shadow: var(--tp-shadow-overlay);
  padding: var(--tp-s3); display: flex; flex-direction: column; gap: 12px;
}
.tp-modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.tp-tooltip {
  display: inline-block; width: fit-content; padding: 7px 10px;
  background: var(--tp-white); border: 1px solid var(--tp-border); border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow-raised); font-size: var(--tp-caption); color: var(--tp-ink);
}
.tp-progress { height: 8px; border-radius: 4px; background: var(--tp-green-50); overflow: hidden; }
.tp-progress > span { display: block; height: 100%; border-radius: 4px; background: var(--tp-green-500); }
.tp-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 3px solid var(--tp-green-50); border-top-color: var(--tp-green-500);
  animation: tp-spin .8s linear infinite;
}
@keyframes tp-spin { to { transform: rotate(360deg); } }
.tp-skeleton { height: 12px; border-radius: var(--tp-radius); background: var(--tp-mist); }

/* ---------- Data display ---------- */
.tp-table { width: 100%; border-collapse: collapse; border: 1px solid var(--tp-border); border-radius: var(--tp-radius-lg); overflow: hidden; font-size: var(--tp-small); }
.tp-table th {
  background: var(--tp-mist); padding: 12px 18px; text-align: left;
  font-family: var(--tp-font-head); font-weight: 700; font-size: var(--tp-caption);
  letter-spacing: .08em; text-transform: uppercase; color: var(--tp-ink);
}
.tp-table td { padding: 13px 18px; border-top: 1px solid var(--tp-border); }
.tp-table tbody tr:hover { background: var(--tp-green-50); }
.tp-table .tp-num { text-align: right; }
.tp-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  font-size: var(--tp-caption); font-weight: 700;
}
.tp-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tp-badge--success { background: var(--tp-success-tint); color: var(--tp-success); }
.tp-badge--warning { background: var(--tp-warning-tint); color: var(--tp-warning); }
.tp-badge--error   { background: var(--tp-error-tint);   color: var(--tp-error); }
.tp-badge--neutral { background: var(--tp-mist); color: var(--tp-body); }
.tp-tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border: 1px solid var(--tp-border); border-radius: 999px;
  font-size: var(--tp-small); color: var(--tp-ink); background: var(--tp-white);
}
.tp-tag button { border: none; background: none; color: var(--tp-steel); cursor: pointer; padding: 0; font-size: var(--tp-small); }
.tp-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--tp-green-50); color: var(--tp-green-700);
  font-family: var(--tp-font-head); font-weight: 700; font-size: var(--tp-caption);
}
.tp-avatar--sm { width: 24px; height: 24px; font-size: 9px; }
.tp-avatar--lg { width: 40px; height: 40px; font-size: var(--tp-small); }
.tp-card {
  background: var(--tp-white); border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-lg); padding: var(--tp-s3);
}
.tp-accordion { border-top: 1px solid var(--tp-border); }
.tp-accordion summary {
  display: flex; justify-content: space-between; align-items: center; gap: var(--tp-s2);
  padding: 12px 0; cursor: pointer; list-style: none;
  font-family: var(--tp-font-head); font-weight: 700; font-size: var(--tp-text); color: var(--tp-ink);
}
.tp-accordion summary::-webkit-details-marker { display: none; }
.tp-accordion summary::after { content: "▾"; color: var(--tp-steel); transition: transform .15s ease-out; }
.tp-accordion[open] summary::after { transform: rotate(180deg); color: var(--tp-green-700); }
.tp-accordion > div { padding: 0 0 14px; font-size: var(--tp-small); border-bottom: 1px solid var(--tp-border); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
