/* Hockeypuck Minimalist Theme - Core CSS System */

/* ============================================
   CSS Custom Properties - Design System
   ============================================ */

:root {
  /* Base palette */
  --color-primary: #2d6b3a;
  --color-secondary: #c5d9c7;
  --color-background: #f3f4f3;
  --color-accent: #e0a020;
  --color-warning: #b5312a;

  /* Interaction colors */
  --color-primary-hover: #245730;
  --color-primary-active: #1b4425;
  --color-primary-light: rgba(45, 107, 58, 0.10);

  /* Text colors */
  --text-primary: #1c2820;
  --text-secondary: #475c4a;
  --text-muted: #6e7d70;
  --text-on-primary: #ffffff;

  /* Surface colors */
  --surface: #ffffff;
  --surface-secondary: #f7f8f7;
  --surface-tertiary: #eef0ee;

  /* Border colors */
  --border: #d3d8d4;
  --border-light: #e4e8e5;
  --border-focus: #2d6b3a;

  /* Shadow system */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.09);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.11);
  --shadow-modal: 0 20px 25px rgba(0, 0, 0, 0.16);
  
  /* Border radius scale */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  
  /* Spacing system (4px base) */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  
  /* Typography scale */
  --font-xs: 0.75rem;     /* 12px - captions, labels */
  --font-sm: 0.875rem;    /* 14px - body small */
  --font-base: 1rem;      /* 16px - body */
  --font-lg: 1.125rem;    /* 18px - lead text */
  --font-xl: 1.25rem;     /* 20px - small headings */
  --font-2xl: 1.5rem;     /* 24px - section headings */
  --font-3xl: 1.875rem;   /* 30px - page title */
  --font-4xl: 2.25rem;    /* 36px - hero title */
  
  /* Base styles */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --line-height-base: 1.5;
}

/* ============================================
   Reset & Base
   ============================================ */

* {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--color-background);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 500;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

h1 { font-size: var(--font-3xl); }
h2 { font-size: var(--font-2xl); font-weight: 600; }
h3 { font-size: var(--font-lg); }

/* clickable site name in page headers */
.site-link {
  color: inherit;
  text-decoration: none;
}

.site-link:hover {
  color: var(--color-primary);
}

p {
  margin-top: 0;
  margin-bottom: var(--space-4);
}

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

a:hover {
  text-decoration: underline;
}

/* ============================================
   Utility Classes
   ============================================ */

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

.mb-0 { margin-bottom: 0; }
.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); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }

@media (min-width: 768px) {
  .grid-md-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
  }
}

/* ============================================
   Container
   ============================================ */

.container {
  padding-right: var(--space-4);
  padding-left: var(--space-4);
  margin-right: auto;
  margin-left: auto;
}

@media (min-width: 768px) {
  .container { max-width: 750px; }
}

@media (min-width: 992px) {
  .container { max-width: 970px; }
}

@media (min-width: 1200px) {
  .container { max-width: 1200px; }
}

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* ============================================
   Form Controls
   ============================================ */

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: var(--font-base);
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-control::placeholder {
  color: var(--text-muted);
}

/* ============================================
   Tables
   ============================================ */

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
}

th:last-child,
td:last-child {
  border-right: none;
}

th {
  background-color: var(--surface-secondary);
  font-weight: 600;
  color: var(--text-secondary);
}

tr:hover {
  background-color: var(--surface-tertiary);
}

tr:nth-child(even) {
  background-color: var(--surface-secondary);
}

tr:nth-child(even):hover {
  background-color: var(--surface-tertiary);
}

tr:last-child td,
tr:last-child th {
  border-bottom: none;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--text-on-primary);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-primary:active {
  background-color: var(--color-primary-active);
  transform: scale(0.98);
}

.btn-secondary {
  background-color: var(--surface-secondary);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background-color: var(--surface-tertiary);
}

.btn-secondary:active {
  background-color: var(--border-light);
  transform: scale(0.98);
}

.btn-warning {
  background-color: var(--color-warning);
  color: var(--text-on-primary);
}

.btn-warning:hover {
  background-color: #9a2722;
}

.btn-warning:active {
  background-color: #7a1d19;
  transform: scale(0.98);
}

/* ============================================
   Modals (Pure CSS)
   ============================================ */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal:target {
  display: block;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 15, 0.45);
  z-index: -1;
  display: block;
  cursor: default;
}

.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 10;
}

.modal-content-lg {
  max-width: 800px;
}

/* ============================================
   Focus States (Accessibility)
   ============================================ */

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

/* Remove default outline when focus-visible is supported */
:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================
   Reduced Motion
   ============================================ */

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

/* ============================================
   Collapsible Panel (Advanced Options, etc.)
   ============================================ */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.panel > summary {
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
}

.panel > summary::-webkit-details-marker {
  display: none;
}

.panel > summary::marker {
  content: '';
}

/* chevron indicator — rotates when open */
.panel > summary::after {
  content: '';
  display: block;
  margin-left: auto;
  flex-shrink: 0;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

details[open].panel > summary::after {
  transform: rotate(-135deg);
}

details[open].panel > summary {
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.panel > summary:hover {
  background: var(--surface-secondary);
  border-radius: var(--radius-md);
}

details[open].panel > summary:hover {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.panel-body {
  padding: var(--space-3) var(--space-4);
}

/* ============================================
   Card + Table layout (stats sections)
   ============================================ */

/* table flush inside a card: card provides container, table provides data grid */
.card-section {
  overflow: hidden;
}

.card-section-header {
  padding: var(--space-3) var(--space-6);
  background: var(--surface-secondary);
  border-left: 3px solid var(--color-primary);
  border-bottom: 1px solid var(--border-light);
}

.card-section-header h2,
.card-section-header h3 {
  margin: 0;
}

.card-section-header p {
  margin: var(--space-1) 0 0;
  color: var(--text-secondary);
  font-size: var(--font-sm);
}

.card-section > table {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

/* ============================================
   Key Detail Sections
   ============================================ */

.key-card {
  overflow: hidden;
  padding: 0;
}

.key-detail {
  /* sections handle their own overflow */
}

/* <details> container */
.key-section {
  display: block;
  border-left: 3px solid transparent;
  margin: 0;
}

.key-section + .key-section {
  border-top: 1px solid var(--border-light);
}

.key-section-pub {
  background: var(--surface-secondary);
  border-left-color: var(--color-primary);
}

.key-section-uid {
  background: var(--surface);
  border-left-color: var(--color-secondary);
}

.key-section-sub {
  background: var(--surface);
  border-left-color: var(--border);
  color: var(--text-secondary);
}

/* <summary> — always-visible header line */
.key-summary {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  display: block;
  list-style: none;
  user-select: none;
}

.key-summary::-webkit-details-marker {
  display: none;
}

.key-summary::marker {
  content: '';
}

.key-summary:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* collapse indicator — only on actual <summary> elements */
summary.key-summary::after {
  content: '  [−]';
  color: var(--text-muted);
  font-size: 0.8em;
  font-weight: 400;
}

details:not([open]) > summary.key-summary::after {
  content: '  [+]';
}

/* collapsible sig block */
.key-sigs {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre;
  overflow-x: auto;
  display: block;
  padding: 0 var(--space-4) var(--space-2) var(--space-4);
  margin: 0;
}

.key-link {
  color: var(--color-primary);
  text-decoration: none;
}

.key-link:hover {
  text-decoration: underline;
}

.key-revok {
  color: var(--color-warning);
  font-weight: bold;
}

.key-uid-name {
  font-weight: 700;
}

/* type badge — <strong>pub/uid/sub</strong> inside summary */
.key-summary strong {
  display: inline-block;
  padding: 0.05em 0.45em;
  border-radius: 3px;
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: baseline;
  line-height: 1.5;
  margin-right: 0.25em;
}

.key-section-pub .key-summary strong {
  background: var(--color-primary);
  color: #fff;
}

.key-section-uid .key-summary strong {
  background: var(--color-secondary);
  color: var(--text-secondary);
}

.key-section-sub .key-summary strong {
  background: var(--surface-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ============================================
   Footer
   ============================================ */

footer {
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-6);
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}