/**
 * Shared styling kit for SimonW-copied static HTML apps
 * Inspired by the homepage visual style
 * 
 * CSS Variables support light/dark mode via prefers-color-scheme
 */

/* ============================================
   CSS Variables (Light/Dark Mode)
   ============================================ */

:root {
  /* Light mode (default) */
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --bg-muted: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --accent-soft: #eff6ff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-elev: #1e293b;
    --bg-muted: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --accent: #60a5fa;
    --accent-2: #a78bfa;
    --accent-soft: #1e3a5f;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  }
}

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

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Layout Classes
   ============================================ */

.page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-muted) 100%);
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
}

.hero {
  text-align: center;
  padding: 2rem 0;
  margin-bottom: 1.5rem;
}

.title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.025em;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin: 0;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

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

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="file"] {
  padding: 0.5rem;
  cursor: pointer;
}

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

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text);
}

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

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  color: #ffffff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.btn:hover,
button:hover {
  background: var(--accent-2);
}

.btn:active,
button:active {
  transform: scale(0.98);
}

.btn:disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

/* ============================================
   Links
   ============================================ */

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

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

/* ============================================
   Code & Preformatted Text
   ============================================ */

code,
kbd {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.875em;
  background: var(--bg-muted);
  padding: 0.2em 0.4em;
  border-radius: 4px;
}

pre {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

pre code {
  background: transparent;
  padding: 0;
  font-size: 0.875rem;
}

kbd {
  background: var(--text);
  color: var(--bg);
  font-size: 0.8em;
  padding: 0.15em 0.4em;
  border-radius: 3px;
  box-shadow: 0 2px 0 var(--border);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

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

th {
  font-weight: 600;
  background: var(--bg-muted);
}

tr:hover {
  background: var(--bg-muted);
}

/* ============================================
   Accessibility
   ============================================ */

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

/* High-contrast selection */
::selection {
  background: var(--accent);
  color: #ffffff;
}

::-moz-selection {
  background: var(--accent);
  color: #ffffff;
}

/* Skip link styling */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent);
  color: #ffffff;
  padding: 0.5rem 1rem;
  z-index: 100;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

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

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

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 640px) {
  .container {
    padding: 1rem;
  }

  .title {
    font-size: 1.5rem;
  }

  .subtitle {
    font-size: 1rem;
  }

  .card {
    padding: 1rem;
  }

  button,
  .btn {
    width: 100%;
  }
}
