/* FIT to Text V6.2 */

@import url('https://fonts.googleapis.com/css2?family=Amaranth:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  color-scheme: light;
  --cycler-gradient-start: rgba(40, 186, 222, 0.85);
  --cycler-gradient-mid-a: #5ec7e6;
  --cycler-gradient-mid-b: #c989b8;
  --cycler-gradient-end: rgba(180, 100, 160, 0.7);
  --cycler-grid-bg-color: #28bade;
  --medium-paper-texture: url('../_images/blue_m.png');
  --panel-bg-image: var(--medium-paper-texture);
  --cycler-button-bg: #5ccbf3;
  --cycler-button-bg-hover: #4aaecf;
  --cycler-button-text: #000000;
  --cycler-button-glow: rgba(180, 100, 160, 0.6);
  --cycler-border: #555;
  --cycler-shadow: rgba(0, 0, 0, 0.4);
  --cycler-hover: #c72a93;
  --accent-text: #7a145a;
  --required-color: #55073c;
  --cycler-glass-bg: rgba(255, 255, 255, 0.25);
  --cycler-glass-border: rgba(255, 255, 255, 0.33);
  --cycler-header-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  --panel-text: #171717;
  --panel-muted: #21333b;
  --strong-text: #111111;
  --heading-text: #222222;
  --heading-copy: rgba(20, 20, 20, 0.78);
  --panel-soft: rgba(255, 255, 255, 0.35);
  --panel-softer: rgba(255, 255, 255, 0.2);
  --field-bg: rgba(255, 255, 255, 0.58);
  --field-text: #111111;
  --help-popover-bg: rgba(236, 250, 253, 0.98);
  --help-popover-text: #123540;
  --help-popover-border: rgba(15, 97, 120, 0.55);
  --success-text: #0b4a3a;
  --danger: #a51535;
}

/* Keep this explicit dark-theme block in sync with the system dark-mode block below. */
html[data-theme="dark"] {
  color-scheme: dark;
  --cycler-gradient-start: rgba(6, 64, 83, 0.96);
  --cycler-gradient-mid-a: #124f63;
  --cycler-gradient-mid-b: #543452;
  --cycler-gradient-end: rgba(58, 24, 61, 0.92);
  --cycler-grid-bg-color: #0f6178;
  --panel-bg-image: linear-gradient(rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.42)), var(--medium-paper-texture);
  --cycler-button-bg: #2b8ead;
  --cycler-button-bg-hover: #24758f;
  --cycler-button-text: #f4fbff;
  --cycler-button-glow: rgba(199, 42, 147, 0.35);
  --cycler-border: #173846;
  --cycler-glass-bg: rgba(4, 26, 35, 0.55);
  --cycler-glass-border: rgba(182, 226, 238, 0.22);
  --panel-text: #eef9fb;
  --panel-muted: #c6dce3;
  --strong-text: #ffffff;
  --heading-text: #f4fbff;
  --heading-copy: rgba(230, 246, 250, 0.82);
  --panel-soft: rgba(2, 18, 25, 0.66);
  --panel-softer: rgba(0, 0, 0, 0.22);
  --field-bg: rgba(2, 17, 24, 0.82);
  --field-text: #f4fbff;
  --help-popover-bg: rgba(31, 111, 132, 0.98);
  --help-popover-text: #f4fbff;
  --help-popover-border: rgba(145, 224, 244, 0.55);
  --success-text: #bdf3e1;
  --accent-text: #ff9add;
  --required-color: var(--accent-text);
  --danger: #ffb4c2;
}

/* Keep these dark token values in sync with html[data-theme="dark"] above. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    color-scheme: dark;
    --cycler-gradient-start: rgba(6, 64, 83, 0.96);
    --cycler-gradient-mid-a: #124f63;
    --cycler-gradient-mid-b: #543452;
    --cycler-gradient-end: rgba(58, 24, 61, 0.92);
    --cycler-grid-bg-color: #0f6178;
    --panel-bg-image: linear-gradient(rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.42)), var(--medium-paper-texture);
    --cycler-button-bg: #2b8ead;
    --cycler-button-bg-hover: #24758f;
    --cycler-button-text: #f4fbff;
    --cycler-button-glow: rgba(199, 42, 147, 0.35);
    --cycler-border: #173846;
    --cycler-glass-bg: rgba(4, 26, 35, 0.55);
    --cycler-glass-border: rgba(182, 226, 238, 0.22);
    --panel-text: #eef9fb;
    --panel-muted: #c6dce3;
    --strong-text: #ffffff;
    --heading-text: #f4fbff;
    --heading-copy: rgba(230, 246, 250, 0.82);
    --panel-soft: rgba(2, 18, 25, 0.66);
    --panel-softer: rgba(0, 0, 0, 0.22);
    --field-bg: rgba(2, 17, 24, 0.82);
    --field-text: #f4fbff;
    --help-popover-bg: rgba(31, 111, 132, 0.98);
    --help-popover-text: #f4fbff;
    --help-popover-border: rgba(145, 224, 244, 0.55);
    --success-text: #bdf3e1;
    --accent-text: #ff9add;
    --required-color: var(--accent-text);
    --danger: #ffb4c2;
  }
}

* {
  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 40s 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: 0 0 32px;
}

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

header {
  width: 95%;
  max-width: 1180px;
  margin: 0.2em auto 0.6em;
  padding: 0.5em 0.7em 0.65em;
  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.8rem);
  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(1rem, 1vw + 0.75rem, 1.25rem);
  line-height: 1.35;
}

.container {
  width: 95%;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1em;
}

.intro-copy,
.seo-details,
.options,
.athlete-context,
.drop-zone,
.status,
.output-box,
.card {
  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);
}

.intro-copy,
.seo-details,
.options,
.athlete-context {
  padding: 0.9em;
}

.intro-copy h2,
.seo-details h2 {
  margin-bottom: 0.35em;
  color: var(--strong-text);
  font-size: clamp(1.2rem, 1.5vw + 0.8rem, 1.7rem);
  font-variant: small-caps;
}

.intro-copy p,
.seo-details p,
.seo-details li {
  color: var(--panel-muted);
  font-size: 1rem;
  line-height: 1.45;
  max-width: 70ch;
}

.faq-list {
  display: grid;
  gap: 0.65em;
}

.faq-list details {
  border: 1px solid var(--cycler-border);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 0.65em 0.8em;
}

.faq-list summary {
  color: var(--strong-text);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1.25;
}

.faq-list summary:hover,
.faq-list details[open] summary {
  color: var(--accent-text);
}

.faq-list details[open] summary {
  margin-bottom: 0.45em;
}

.faq-list p {
  padding-left: 1.2em;
}

.options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75em 1em;
}

.include-options {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75em 1em;
  min-inline-size: 0;
  border: 0;
  padding: 0;
  margin: 0;
}

.include-options legend {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
}

.include-options legend,
.options label,
.theme-mode,
.athlete-context label,
.output-header label,
.card-label {
  color: var(--panel-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.include-options legend,
.output-header label,
.card-label {
  text-transform: uppercase;
}

.options label,
.theme-mode {
  display: flex;
  align-items: center;
  gap: 0.4em;
  cursor: pointer;
}

.options input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--cycler-hover);
  cursor: pointer;
  opacity: 1;
  position: relative;
}

.theme-mode {
  /* Aligns to start when wrapped on narrow screens */
}

.theme-mode select,
.athlete-context input,
.athlete-context select,
.athlete-context textarea {
  width: 100%;
  color: var(--field-text);
  background: var(--field-bg);
  border: 1px solid var(--cycler-border);
  border-radius: 6px;
  font: inherit;
  padding: 0.45em 0.55em;
}

.theme-mode select {
  width: auto;
}

.athlete-context input,
.athlete-context select {
  height: 3rem;
  line-height: 1.2;
}

.theme-mode select:focus,
.athlete-context input:focus,
.athlete-context select:focus,
.athlete-context textarea:focus,
textarea:focus {
  outline: none;
  border-color: var(--cycler-hover);
  box-shadow: 0 0 0 3px rgba(199, 42, 147, 0.22);
}

.athlete-context {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em;
}

.required-note {
  width: 100%;
  margin: 0 0 0.15em;
  color: var(--panel-muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.required-note span,
.required-marker {
  color: var(--required-color);
  font-weight: 700;
}

.field {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 140px;
  gap: 0.25em;
  min-width: 0;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.3em;
  min-height: 1.45rem;
}

.field-label-row label {
  min-width: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.required-marker {
  font-size: 1.1em;
  line-height: 1;
  margin-left: 0.15em;
}

.optional-field .required-marker {
  display: none;
}

.field-help-text {
  display: none;
  position: absolute;
  z-index: 20;
  top: 1.8rem;
  left: var(--help-popover-left, 0);
  width: max-content;
  max-width: min(14.5rem, 72vw);
  padding: 0.55em 0.65em;
  color: var(--help-popover-text);
  background: var(--help-popover-bg);
  border: 1px solid var(--help-popover-border);
  border-radius: 6px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  font-size: 0.78rem;
  line-height: 1.3;
  pointer-events: none;
  transform: translateX(-0.05rem);
}

.field-help-text:focus {
  outline: 2px solid var(--cycler-hover);
  outline-offset: 2px;
}

.field.help-open .field-help-text {
  display: block;
}

.ride-notes-field .field-help-text {
  max-width: min(18rem, 72vw);
}

.athlete-context textarea {
  min-height: 5.4rem;
  resize: vertical;
  line-height: 1.4;
}

.ride-notes-field {
  flex: 1 1 100%;
}

.ride-context-field {
  flex: 2 1 280px;
}

.second-row-start {
  /* auto flow in flex container */
}

.convert-actions {
  display: flex;
  width: 100%;
  justify-content: center;
}

.drop-zone {
  position: relative;
  overflow: hidden;
  padding: 1.45em 1.2em;
  text-align: center;
  cursor: pointer;
  transition: box-shadow 0.15s ease-out, transform 0.15s ease-out, border-color 0.15s ease-out;
}

.drop-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.16);
  opacity: 0;
  transition: opacity 0.15s ease-out;
}

.drop-zone:hover,
.drop-zone.dragover,
.drop-zone:focus-within {
  transform: translateY(2px);
  border-color: var(--cycler-hover);
  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);
}

.drop-zone:hover::before,
.drop-zone.dragover::before,
.drop-zone:focus-within::before {
  opacity: 1;
}

.drop-zone > * {
  position: relative;
  z-index: 1;
}

.drop-icon {
  display: block;
  margin-bottom: 0.2em;
  font-size: 2.1rem;
}

.drop-zone h2 {
  margin-bottom: 0.15em;
  color: var(--strong-text);
  font-size: clamp(1.2rem, 1.5vw + 0.75rem, 1.7rem);
}

.drop-zone p {
  color: var(--panel-muted);
  font-size: 1rem;
}

.choose-file-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.75em;
  min-height: 2.35rem;
  padding: 0.35em 0.8em;
  color: var(--cycler-button-text);
  background-color: var(--cycler-button-bg);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.05) 51%,
    rgba(0, 0, 0, 0.1) 100%
  );
  border: 1px solid var(--cycler-border);
  border-radius: 6px;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.6),
    inset -1px -1px 0 rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 12px var(--cycler-button-glow);
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out, transform 0.15s ease-out;
  user-select: none;
}

.drop-zone:hover .choose-file-action,
.choose-file-action:hover {
  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);
}

input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

input[type="file"]:focus-visible {
  outline: none;
}

input[type="file"]:focus-visible ~ .choose-file-action {
  outline: 3px solid var(--cycler-hover);
  outline-offset: 2px;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.6em;
  max-height: 0;
  overflow: hidden;
  padding: 0 0.9em;
  color: var(--success-text);
  font-weight: 700;
  opacity: 0;
  transition: max-height 0.15s ease-out, opacity 0.15s ease-out, padding 0.15s ease-out;
}

.status.visible {
  max-height: 5rem;
  padding: 0.75em 0.9em;
  opacity: 1;
}

.status.error {
  color: var(--danger);
  border-color: var(--danger);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: var(--cycler-hover);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.output-section {
  display: none;
  flex-direction: column;
  gap: 0.8em;
}

.output-section.visible {
  display: flex;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6em;
}

.card {
  min-width: 0;
  padding: 0.65em;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.card:hover {
  border-color: var(--cycler-hover);
  box-shadow: 0 0 15px var(--cycler-button-glow);
}

.card-label {
  margin-bottom: 0.25em;
  white-space: nowrap;
}

.card-value {
  color: var(--strong-text);
  font-size: clamp(1rem, 1vw + 0.75rem, 1.35rem);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.card-unit {
  margin-left: 0.15em;
  color: var(--panel-muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.output-box {
  overflow: hidden;
}

.output-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8em;
  padding: 0.7em 0.85em;
  border-bottom: 1px solid var(--cycler-border);
  background: var(--panel-softer);
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45em;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.35em 0.8em;
  color: var(--cycler-button-text);
  background-color: var(--cycler-button-bg);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.05) 51%,
    rgba(0, 0, 0, 0.1) 100%
  );
  border: 1px solid var(--cycler-border);
  border-radius: 6px;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.6),
    inset -1px -1px 0 rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.2),
    0 0 12px var(--cycler-button-glow);
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  line-height: 1.15;
  text-align: center;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.3);
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out, transform 0.15s ease-out;
}

button:hover,
button.primary:hover {
  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);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.35),
    inset -1px -1px 0 rgba(0, 0, 0, 0.08);
}

button:disabled:hover {
  background-color: var(--cycler-button-bg);
  background-image: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.4) 0%,
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 0, 0, 0.05) 51%,
    rgba(0, 0, 0, 0.1) 100%
  );
  transform: none;
}

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

button.field-help {
  min-width: 1.5rem;
  min-height: 1.5rem;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  flex: 0 0 auto;
  color: var(--panel-muted);
  background: var(--panel-soft);
  background-image: none;
  border-color: var(--cycler-glass-border);
  border-radius: 50%;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.25);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.1;
  text-shadow: none;
  transform: none;
}

button.field-help:hover,
button.field-help:focus {
  color: var(--cycler-button-text);
  background: var(--cycler-button-bg);
  background-image: none;
  box-shadow: 0 0 8px var(--cycler-button-glow);
  transform: none;
}

.convert-button {
  min-width: min(100%, 18rem);
  min-height: 3.1rem;
  padding: 0.55em 1.25em;
  font-size: clamp(1.05rem, 1vw + 0.8rem, 1.35rem);
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 320px;
  padding: 1em;
  color: var(--field-text);
  background: var(--field-bg);
  border: none;
  font: 0.82rem/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.athlete-context .ride-notes-field textarea {
  min-height: 5.4rem;
  padding: 0.65em 0.7em;
  font: inherit;
  line-height: 1.35;
}

footer {
  margin-top: 2em;
  padding: 1em;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
  text-align: center;
}

@media (min-width: 48rem) {
  header,
  .container {
    width: 85%;
  }
}

@media (max-width: 48rem) {
  .btn-group {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  body,
  .spinner {
    animation: none;
  }
}
