/* index.css - TT Lap Calculator Stylesheet (v2.5) */

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

/* ============================================================================
   GLOBAL STYLES
   ============================================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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: 860px;
  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: 860px;
  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);
}

/* ============================================================================
   FORM LAYOUT (ROWS)
   ============================================================================ */
.calculator-rows {
  display: flex;
  flex-direction: column;
  gap: 1.25em;
  margin-top: 0.5em;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5em;
}

.form-row.row-centered {
  display: flex;
  justify-content: center;
}

.centered-field {
  width: 100%;
  max-width: calc(50% - 0.75em);
}

@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 1.1em;
  }
  .form-row.row-centered {
    display: block;
  }
  .centered-field {
    max-width: none;
  }
}

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

.label-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.link-btn {
  background: none;
  border: none;
  color: var(--cycler-hover);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: underline;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.2);
}

.link-btn:hover {
  color: var(--strong-text);
}

/* ============================================================================
   CONTROLS (Inputs, Selects, and Ranges)
   ============================================================================ */
input[type="number"],
select {
  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;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--cycler-hover);
  box-shadow: 0 0 0 3px rgba(199, 42, 147, 0.22);
}

.range-wrapper {
  height: 2.8rem;
  display: flex;
  align-items: center;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--panel-softer);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cycler-button-bg);
  border: 1px solid var(--cycler-border);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.1rem;
  margin-top: 0.5em;
  padding: 0.55em 1.25em;
  font-size: clamp(1.05rem, 1vw + 0.8rem, 1.35rem);
  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 {
  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(2px);
  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 {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

.primary-button:active {
  transform: translateY(3px);
}

/* ============================================================================
   RESULTS PANEL
   ============================================================================ */
.results-container {
  margin-top: 1.5em;
  display: flex;
  flex-direction: column;
  gap: 0.8em;
}

.results-panel {
  background: var(--panel-soft);
  border: 1px solid var(--cycler-border);
  border-radius: 12px;
  padding: 1.5em;
  text-align: center;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.2);
}

.result-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
  margin-bottom: 1.2em;
  padding-bottom: 1.2em;
  border-bottom: 1px solid var(--cycler-border);
}

.result-hero .result-label {
  font-size: 1rem;
  color: var(--panel-muted);
  font-weight: 700;
  text-transform: uppercase;
}

.result-value-large {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--strong-text);
  line-height: 1;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2em;
}

.result-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
}

.result-item .result-value {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--strong-text);
}

.result-item .result-label {
  font-size: 0.82rem;
  color: var(--panel-muted);
  text-transform: uppercase;
  font-weight: 700;
}

/* Tech Specs Block */
.tech-specs-panel {
  background: var(--panel-softer);
  border: 1px solid var(--cycler-border);
  border-radius: 8px;
  padding: 1em;
}

.specs-title {
  margin-bottom: 0.8em;
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--panel-muted);
  text-align: center;
}

.specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6em;
  font-size: 0.88rem;
}

.spec-item {
  display: flex;
  justify-content: space-between;
  padding: 0.2em 0.4em;
}

.spec-label {
  color: var(--panel-muted);
}

.spec-item span:last-child {
  color: var(--strong-text);
  font-weight: 700;
}

/* ============================================================================
   MODALS
   ============================================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 2, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background-color: var(--cycler-grid-bg-color);
  background-image: var(--panel-bg-image);
  border: 2px solid var(--cycler-hover);
  border-radius: 20px;
  padding: 2em;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.modal-header h3 {
  font-size: 1.4rem;
  font-weight: 700;
  font-variant: small-caps;
  color: var(--heading-text);
  margin-bottom: 0.2em;
}

.modal-header p {
  font-size: 0.9rem;
  color: var(--panel-muted);
}

.modal-actions {
  display: flex;
  gap: 0.8em;
  margin-top: 0.5em;
}

.secondary-button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.6rem;
  padding: 0.4em 1em;
  color: var(--cycler-button-text);
  background-color: var(--panel-soft);
  border: 1px solid var(--cycler-border);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background-color 0.15s ease-out;
}

.secondary-button:hover {
  background-color: rgba(255, 255, 255, 0.5);
}

.modal-btn {
  flex: 1;
  margin-top: 0;
  min-height: 2.6rem;
}

/* ============================================================================
   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: 860px;
  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: 520px) {
  .container {
    padding: 16px;
  }
  .results-grid {
    grid-template-columns: 1fr;
  }
}

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

  input[type="number"],
  select,
  .tech-specs-panel {
    corner-shape: squircle;
  }
}

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