/* HACC TT Tracker Stylesheet - Site Visual Alignment */

@import url('../variables.css');

/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: linear-gradient(
    -45deg,
    var(--cycler-gradient-start),
    var(--cycler-gradient-mid-a),
    var(--cycler-gradient-mid-b),
    var(--cycler-gradient-end)
  );
  background-size: 320% 320%;
  background-attachment: fixed;
  background-color: #313131;
  animation: cycler-gradient 18s ease-in-out infinite;
  color: var(--panel-text);
  font-family: 'Amaranth', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: clamp(16px, 0.3vw + 15px, 18px);
  line-height: 1.6;
  padding: 20px 0 40px;
}

@keyframes cycler-gradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.hidden {
  display: none !important;
}

/* ============================================================================
   HEADER BLOCK
   ============================================================================ */
header {
  width: 95%;
  max-width: 960px;
  margin: 0.5em auto 0.8em;
  padding: 0.6em 0.8em 0.75em;
  text-align: center;
  background: var(--cycler-glass-bg);
  border: 1px solid var(--cycler-glass-border);
  border-radius: 20px;
  box-shadow: var(--cycler-header-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

header h1 {
  color: var(--heading-text);
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  font-variant: small-caps;
  font-weight: 700;
  line-height: 1.12;
}

header p {
  max-width: 75ch;
  margin: 0.35em auto 0;
  color: var(--heading-copy);
  font-size: clamp(0.9rem, 1vw + 0.7rem, 1.1rem);
  line-height: 1.35;
}

/* ============================================================================
   CONTAINER
   ============================================================================ */
.container {
  width: 95%;
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.1em;
  padding: 32px;
  background-color: var(--cycler-grid-bg-color);
  background-image: var(--panel-bg-image);
  border: 1px solid var(--cycler-border);
  border-radius: 20px;
  box-shadow: 1px 1px 4px 0 var(--cycler-shadow);
}

/* ============================================================================
   ACTIONS PANEL
   ============================================================================ */
.footer-actions {
  display: flex;
  justify-content: center;
  margin-top: 1em;
}

/* ============================================================================
   STATUS MESSAGES
   ============================================================================ */
.status-message {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--cycler-border);
  margin-bottom: 0.5em;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.status-error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-text);
}

.status-success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-text);
}

/* ============================================================================
   CHART WIDGET
   ============================================================================ */
.chart-wrapper {
  height: 380px;
  width: 100%;
  padding: 20px;
  background: var(--panel-soft);
  border: 1px solid var(--cycler-border);
  border-radius: 12px;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2);
}

.action-bar {
  display: flex;
  justify-content: flex-end;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.primary-button,
.secondary-button,
.submit-btn,
.data-table button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.45em 1.25em;
  font-size: 1rem;
  font-weight: 700;
  color: var(--cycler-button-text);
  background-color: var(--cycler-button-bg);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.40)  0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.05)       51%,
    rgba(0, 0, 0, 0.10)      100%
  );
  box-shadow:
    inset  1px  1px 0px rgba(255, 255, 255, 0.6),
    inset -1px -1px 0px rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 12px var(--cycler-button-glow);
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
  border: 1px solid var(--cycler-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease-out,
              box-shadow       0.15s ease-out,
              transform        0.15s ease-out;
}

.primary-button:hover,
.primary-button:focus,
.secondary-button:hover,
.secondary-button:focus,
.submit-btn:hover,
.submit-btn:focus {
  background-color: var(--cycler-button-bg-hover);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.5)  0%,
    rgba(255, 255, 255, 0.1) 100%
  );
  transform: translateY(1.5px);
  box-shadow:
    inset  2px  2px 6px rgba(0, 0, 0, 0.2),
    inset -1px -1px 4px rgba(255, 255, 255, 0.1),
    0 0 15px var(--cycler-button-glow);
  outline: none;
}

.primary-button:focus-visible,
.secondary-button:focus-visible,
.submit-btn:focus-visible {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

.primary-button:active,
.secondary-button:active,
.submit-btn:active {
  transform: translateY(3px);
}

/* Make primary-button (e.g. Save Record/Download CSV) stand out like game buttons */
.submit-btn {
  background-color: var(--cycler-hover);
  color: #ffffff;
  border-color: var(--cycler-hover);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 14px rgba(199, 42, 147, 0.5);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.2) 0%,
    rgba(255, 255, 255, 0.02) 50%,
    rgba(0, 0, 0, 0.05) 51%,
    rgba(0, 0, 0, 0.15) 100%
  );
}

.submit-btn:hover,
.submit-btn:focus {
  background-color: #b01b80;
  box-shadow: 0 0 18px rgba(199, 42, 147, 0.7);
}

/* ============================================================================
   FORM PANEL
   ============================================================================ */
.form-panel {
  background: var(--panel-soft);
  border: 1px solid var(--cycler-border);
  padding: 24px;
  border-radius: 12px;
  animation: slideDownFade 0.3s ease-out forwards;
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-label {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--strong-text);
  border-bottom: 2px solid var(--cycler-border);
  padding-bottom: 0.2em;
  margin-bottom: 0.8em;
  letter-spacing: 0.05em;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.1em;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--panel-muted);
}

input,
textarea {
  width: 100%;
  height: 2.8rem;
  padding: 0.45em 0.65em;
  background: var(--field-bg);
  color: var(--field-text);
  border: 1px solid var(--cycler-border);
  border-radius: 6px;
  font: inherit;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--cycler-hover);
  box-shadow: 0 0 0 3px rgba(199, 42, 147, 0.22);
}

textarea {
  min-height: 4.8rem;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.1em;
}

/* ============================================================================
   TABLE STYLING
   ============================================================================ */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--cycler-border);
  border-radius: 12px;
  background: var(--panel-soft);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.15);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
  font-size: 0.95rem;
}

.data-table th {
  padding: 14px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--panel-muted);
  border-bottom: 2px solid var(--cycler-border);
  background: var(--panel-softer);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--cycler-border);
  color: var(--panel-text);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: var(--panel-softer);
}

.primary-col {
  font-weight: 700;
}

.highlight-col {
  font-weight: 700;
  color: var(--cycler-hover);
  font-variant-numeric: tabular-nums;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.1);
}

.notes-col {
  white-space: normal;
  min-width: 200px;
  font-size: 0.88rem;
  color: var(--panel-muted);
}

.icon-btn-delete {
  background: none;
  border: none;
  color: var(--panel-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s;
}

.icon-btn-delete:hover {
  background-color: var(--error-bg);
  color: var(--error-text);
}

.empty-state {
  text-align: center;
  color: var(--panel-muted);
  padding: 32px !important;
  font-weight: 700;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
/* ============================================================================
   THEME SWITCHER
   ============================================================================ */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25em;
  width: fit-content;
  max-width: 95%;
  margin: 0;
  padding: 0.22em;
  color: var(--cycler-theme-text);
  background: var(--cycler-theme-bg);
  border: 1px solid var(--cycler-glass-border);
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(45, 4, 82, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.theme-toggle button {
  appearance: none;
  -webkit-appearance: none;
  min-height: 1.9rem;
  padding: 0.25em 0.58em;
  color: var(--cycler-theme-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: clamp(13px, 0.45vw + 0.65rem, 16px);
  line-height: 1;
  transition: background-color 0.15s ease-out,
              border-color 0.15s ease-out,
              box-shadow 0.15s ease-out,
              transform 0.15s ease-out;
}

.theme-toggle button:hover,
.theme-toggle button:focus {
  background: var(--cycler-theme-active-bg);
  border-color: var(--cycler-glass-border);
  outline: none;
}

.theme-toggle button[aria-pressed="true"] {
  color: var(--cycler-button-text);
  background-color: var(--cycler-button-bg);
  border-color: var(--cycler-border);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.35),
    0 0 10px var(--cycler-button-glow);
}

.theme-toggle button:focus-visible {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1em;
  width: 95%;
  max-width: 960px;
  margin: 2em auto 1.5em auto;
  padding: 1.2em 1em;
  color: var(--panel-text);
  font-size: 0.9em;
  border: 1px solid var(--cycler-border);
  background-color: var(--cycler-grid-bg-color);
  background-image: var(--panel-bg-image);
  border-radius: 20px;
  box-shadow: 1px 1px 4px 0 var(--cycler-shadow);
  box-sizing: border-box;
}

footer p {
  margin: 0;
}

/* ============================================================================
   RESPONSIVE & SQUIRCLE SUPPORT
   ============================================================================ */
@media (max-width: 768px) {
  .container {
    padding: 16px;
    border-radius: 20px; /* Preserve card rounding on smaller viewports */
  }
  .hide-mobile {
    display: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .chart-wrapper {
    height: 280px;
    padding: 10px;
  }
}

@supports (corner-shape: squircle) {
  .container,
  .form-panel {
    corner-shape: squircle;
  }

  .status-message,
  .chart-wrapper,
  input,
  textarea,
  .table-responsive {
    corner-shape: squircle;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
    background-position: 0% 50%;
  }
  .form-panel {
    animation: none;
  }
}

/* Spacing and layout utility classes (moved from inline styles) */
.mt-16 {
  margin-top: 16px;
}
.mt-24 {
  margin-top: 24px;
}
.mt-32 {
  margin-top: 32px;
}
.csv-download-btn {
  text-decoration: none;
  display: inline-block;
  text-align: center;
}