/* ==========================================================================
   Sauropod — Application Styles
   Color palette:
     --green-dark:   #2d5a3d   headings, brand, strong accents
     --green:        #4a7c59   primary buttons, links, active states
     --green-mid:    #6a9e78   secondary accents, borders
     --green-light:  #e8f0eb   hover backgrounds, tag fills
     --green-faint:  #f2f5f2   page background tint
     --off-white:    #f7f7f3   page background
     --surface:      #ffffff   cards, inputs
     --text:         #1a2e1e   primary text
     --text-muted:   #6b7c6e   secondary text, labels
     --border:       #d0dbd3   borders, dividers
     --error:        #b03a2e   error text/borders
     --error-bg:     #fdf0ee   error flash background
   ========================================================================== */

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: #1a2e1e;
  background-color: #f7f7f3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4 {
  color: #2d5a3d;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

h1 { font-size: 1.75rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.25rem; margin-top: 1.75rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.05rem; margin-top: 1.25rem; }

p { margin-bottom: 0.75rem; }
p:last-child { margin-bottom: 0; }

a {
  color: #4a7c59;
  text-decoration: none;
}
a:hover { color: #2d5a3d; text-decoration: underline; }

small { font-size: 0.82rem; color: #6b7c6e; }

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background: #e8f0eb;
  color: #2d5a3d;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

pre {
  background: #f2f5f2;
  border: 1px solid #d0dbd3;
  border-radius: 6px;
  padding: 1rem 1.125rem;
  overflow-x: auto;
  margin: 0.75rem 0 1rem;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  color: #1a2e1e;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.site-header {
  background: #ffffff;
  border-bottom: 1px solid #d0dbd3;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  font-size: 1.8rem;
  font-weight: 700;
  color: #2d5a3d;
  letter-spacing: -0.02em;
}
.nav-brand:hover { color: #4a7c59; text-decoration: none; }

.nav-logo {
  height: 80px;
  width: auto;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.92rem;
}

.nav-links a { color: #1a2e1e; }
.nav-links a:hover { color: #4a7c59; text-decoration: none; }

.nav-username {
  color: #6b7c6e;
  font-size: 0.88rem;
}

.container {
  flex: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.82rem;
  color: #6b7c6e;
  border-top: 1px solid #d0dbd3;
  margin-top: auto;
}

.footer-icon {
  display: block;
  margin: 0.4rem auto 0;
  width: 28px;
  height: auto;
  opacity: 0.45;
}

/* --------------------------------------------------------------------------
   Flash messages
   -------------------------------------------------------------------------- */

.flash {
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}

.flash-notice {
  background: #e8f0eb;
  border: 1px solid #6a9e78;
  color: #2d5a3d;
}

.flash-alert {
  background: #fdf0ee;
  border: 1px solid #c9867e;
  color: #7a2a22;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-block;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.5rem 1.1rem;
  border-radius: 5px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.btn-primary {
  background: #4a7c59;
  color: #ffffff;
  border-color: #4a7c59;
}
.btn-primary:hover {
  background: #2d5a3d;
  border-color: #2d5a3d;
  color: #ffffff;
  text-decoration: none;
}

.btn-secondary {
  background: #ffffff;
  color: #4a7c59;
  border-color: #6a9e78;
}
.btn-secondary:hover {
  background: #e8f0eb;
  color: #2d5a3d;
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: #6b7c6e;
  border-color: #d0dbd3;
}
.btn-ghost:hover {
  background: #f2f5f2;
  color: #1a2e1e;
  text-decoration: none;
}

.btn-danger {
  background: #ffffff;
  color: #b03a2e;
  border-color: #c9867e;
}
.btn-danger:hover {
  background: #fdf0ee;
  text-decoration: none;
}

.btn-sm { font-size: 0.82rem; padding: 0.3rem 0.75rem; }

/* Turbo/Rails button_to wraps in a form — strip the form wrapper */
.btn-ghost form,
.nav-links form {
  display: inline;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form-group,
form > div {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: #2d5a3d;
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  max-width: 420px;
  padding: 0.5rem 0.7rem;
  border: 1px solid #d0dbd3;
  border-radius: 5px;
  font-size: 0.95rem;
  color: #1a2e1e;
  background: #ffffff;
  transition: border-color 0.12s, box-shadow 0.12s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
  outline: none;
  border-color: #4a7c59;
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

input[type="submit"],
button[type="submit"] {
  margin-top: 0.5rem;
  background: #4a7c59;
  color: #ffffff;
  border: 1px solid #4a7c59;
  border-radius: 5px;
  padding: 0.5rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}

input[type="submit"]:hover,
button[type="submit"]:hover {
  background: #2d5a3d;
  border-color: #2d5a3d;
}

form small {
  display: block;
  margin-top: 0.25rem;
}

/* --------------------------------------------------------------------------
   Error list (signup/edit validation)
   -------------------------------------------------------------------------- */

.errors {
  background: #fdf0ee;
  border: 1px solid #c9867e;
  border-radius: 6px;
  padding: 0.75rem 1rem 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
  color: #7a2a22;
  font-size: 0.9rem;
}

.errors li { margin-bottom: 0.2rem; }
.errors li:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: #ffffff;
  border: 1px solid #d0dbd3;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  margin: 0.75rem 0 1.25rem;
}

thead tr {
  border-bottom: 2px solid #d0dbd3;
}

th {
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7c6e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem;
}

td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #e8f0eb;
  color: #1a2e1e;
}

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

tbody tr:hover td { background: #f2f5f2; }

/* --------------------------------------------------------------------------
   Definition lists (stat summaries)
   -------------------------------------------------------------------------- */

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1.5rem;
  margin: 0.5rem 0 1.25rem;
  font-size: 0.95rem;
}

dt {
  color: #6b7c6e;
  font-size: 0.88rem;
}

dd {
  font-weight: 600;
  color: #2d5a3d;
}

/* --------------------------------------------------------------------------
   Page-specific: home / landing
   -------------------------------------------------------------------------- */

.hero {
  text-align: center;
  padding: 3.5rem 1rem 2.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.hero p {
  font-size: 1.1rem;
  color: #6b7c6e;
  max-width: 480px;
  margin: 0 auto 1.75rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   Page-specific: auth forms
   -------------------------------------------------------------------------- */

.auth-form {
  max-width: 400px;
  margin: 2rem auto;
  background: #ffffff;
  border: 1px solid #d0dbd3;
  border-radius: 8px;
  padding: 2rem;
}

.auth-form h1 {
  margin-bottom: 1.25rem;
}

.auth-form p {
  margin-top: 1rem;
  font-size: 0.88rem;
  color: #6b7c6e;
}

/* --------------------------------------------------------------------------
   Page-specific: sites list
   -------------------------------------------------------------------------- */

.site-list {
  list-style: none;
  margin: 0.5rem 0 1.25rem;
}

.site-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #e8f0eb;
  font-size: 0.95rem;
}

.site-favicon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.site-list li:last-child { border-bottom: none; }

.site-list .site-domain {
  color: #6b7c6e;
  font-size: 0.85rem;
}

.site-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Page-specific: stats
   -------------------------------------------------------------------------- */

.stats-header {
  margin-bottom: 1.5rem;
}

.stats-header .breadcrumb {
  font-size: 0.85rem;
  color: #6b7c6e;
  margin-bottom: 0.5rem;
}

.stats-header .breadcrumb a { color: #4a7c59; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0 1.5rem;
}

.stat-box {
  background: #ffffff;
  border: 1px solid #d0dbd3;
  border-radius: 7px;
  padding: 0.9rem 1rem;
}

.stat-box .stat-label {
  font-size: 0.78rem;
  color: #6b7c6e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}

.stat-box .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #2d5a3d;
  line-height: 1.1;
}

/* --------------------------------------------------------------------------
   Snippet block (sites#show)
   -------------------------------------------------------------------------- */

.snippet-note {
  font-size: 0.88rem;
  color: #6b7c6e;
  margin-bottom: 0.25rem;
}

/* --------------------------------------------------------------------------
   Inline link actions (edit | delete rows)
   -------------------------------------------------------------------------- */

.row-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.85rem;
}

.row-actions form { display: inline; }

/* --------------------------------------------------------------------------
   Sauropod player widget (on embedding sites — not the dashboard)
   -------------------------------------------------------------------------- */

/* Override player accent to match site theme when previewed on dashboard */
.sauropod-preview .sauropod {
  --sauropod-accent: #4a7c59;
  max-width: 100%;
}

/* --------------------------------------------------------------------------
   Utility
   -------------------------------------------------------------------------- */

.text-muted { color: #6b7c6e; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.page-actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; align-items: center; }

/* --------------------------------------------------------------------------
   Invite code
   -------------------------------------------------------------------------- */

.invite-code-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #d0dbd3;
}

.invite-code {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: #f2f5f2;
  border: 1px solid #d0dbd3;
  border-radius: 6px;
  font-size: 1.25rem;
  letter-spacing: 0.15em;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  color: #2d5a3d;
  user-select: all;
}

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */

.chart-wrap {
  background: #ffffff;
  border: 1px solid #d0dbd3;
  border-radius: 8px;
  padding: 1rem 1.25rem 0.75rem;
  margin: 0.75rem 0 1.5rem;
}

/* --------------------------------------------------------------------------
   Geo section
   -------------------------------------------------------------------------- */

.geo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .geo-grid { grid-template-columns: 1fr; }
}

.geo-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--green-dark);
  margin: 0 0 0.5rem;
}

.geo-table {
  width: 100%;
  font-size: 0.875rem;
}

.geo-table th,
.geo-table td {
  padding: 0.3rem 0.5rem;
}

.geo-table th {
  text-align: left;
  font-weight: 600;
  color: #666;
  border-bottom: 1px solid #d0dbd3;
}

.geo-bar-col {
  width: 120px;
}

.geo-bar {
  height: 8px;
  background: var(--green);
  border-radius: 4px;
  min-width: 2px;
}

/* --------------------------------------------------------------------------
   Period filter
   -------------------------------------------------------------------------- */

.period-filter {
  display:     flex;
  gap:         0.3rem;
  flex-wrap:   wrap;
  margin:      1.25rem 0 1rem;
}

.period-btn {
  padding:       0.3rem 0.85rem;
  border-radius: 999px;
  font-size:     0.82rem;
  font-weight:   500;
  border:        1px solid #d0dbd3;
  color:         #6b7c6e;
  background:    #ffffff;
  text-decoration: none;
  transition:    background 0.1s, color 0.1s, border-color 0.1s;
}

.period-btn:hover {
  background:   #e8f0eb;
  border-color: #6a9e78;
  color:        #2d5a3d;
  text-decoration: none;
}

.period-btn-active {
  background:   #4a7c59;
  border-color: #4a7c59;
  color:        #ffffff;
}

.period-btn-active:hover {
  background:   #2d5a3d;
  border-color: #2d5a3d;
  color:        #ffffff;
}
