/* =========================================
   THEME TOKENS & GLOBAL VARIABLES
   ========================================= */
:root {
  --pc-font: "Inter", sans-serif;
  --pc-bg: #fff;
  --pc-card-border: #ddd;
  --pc-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);

  --pc-accent: #28a26f;
  --pc-accent-contrast: #fff;
  --pc-muted: #ccc;
  --pc-text-muted: #888;

  --pc-radius-lg: 24px;
  --pc-radius-xl: 32px;
  --pc-radius-card: 16px;

  --pc-gap-sm: 0.5rem;
  --pc-gap-md: 0.75rem;
  --pc-pad-sm: 0.6rem;
  --pc-pad-md: 0.75rem;

  --pc-btn-primary: #f4c542;
  --pc-btn-info: #f9d75d;

  --pc-chevron: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%2328a26f' stroke-width='2' d='M1 1l5 5 5-5'/></svg>");

  --pc-hero-height: 820px;
  --pc-hero-bg: #4bb688;
}

/* =========================================
         BASE TYPOGRAPHY
         ========================================= */
h2 {
  font-family: "Montserrat", sans-serif;
}

/* =========================================
         CORE LAYOUT CONTAINERS
         ========================================= */
.pace-wrapper {
  max-width: 620px;
}

.pace-calculator {
  padding: 1.5rem;
  border: 1px solid var(--pc-card-border);
  border-radius: var(--pc-radius-card);
  background: var(--pc-bg);
  font-family: var(--pc-font);
  box-shadow: var(--pc-shadow);
  margin-top: 1rem;
  position: relative;
  z-index: 1;
}

.pace-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  color: #fff;
  font-family: Montserrat;
  font-weight: 700;
  font-style: italic;
  font-size: 24px;
  line-height: 44px;
  letter-spacing: 0px;
  vertical-align: middle;
}

/* Keep layout predictable inside the calculator */
.pace-calculator,
.pace-calculator * {
  box-sizing: border-box;
}

/* =========================================
         INFO BUTTON & TOOLTIP
         ========================================= */
.btn-info {
  background: var(--pc-btn-info);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-weight: 700;
  cursor: pointer;
  font-size: 18px;
  line-height: 20px;
  position: relative;
}

/* base: no tooltip boxes exist */
.btn-info::after,
.btn-info::before {
  content: none;
}

/* show on hover/focus/active */
.btn-info:hover::after,
.btn-info:focus::after,
.btn-info.active::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.2;
  padding: 6px 10px;
  border-radius: 6px;
  min-width: 160px;
  max-width: 240px;
  white-space: normal;
  word-break: break-word;
  z-index: 10;
}
.btn-info:hover::before,
.btn-info:focus::before,
.btn-info.active::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #000;
  z-index: 10;
}

/* =========================================
         SECTIONS & LABELS
         ========================================= */
.form-section {
  margin-bottom: 1.5rem;
}

.section-label {
  margin-bottom: 0.5rem;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 24px;
  line-height: 100%;
  letter-spacing: 0px;
  vertical-align: middle;
}

/* =========================================
         ROW LAYOUTS
         ========================================= */
.distance-row,
.time-row,
.pace-row {
  display: flex;
  gap: var(--pc-gap-sm);
}

/* =========================================
         FORM TYPOGRAPHY & BASE CONTROLS
         ========================================= */
.pace-calculator input,
.pace-calculator select,
.pace-calculator textarea {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-style: normal;
  font-size: 16px;
  line-height: 18px;
  letter-spacing: 0px;
  vertical-align: middle;
}

input,
select {
  flex: 1;
  padding: var(--pc-pad-sm);
  border: 1px solid var(--pc-muted);
  border-radius: 8px;
  font-size: 0.95rem;
}

/* =========================================
         CAPSULE (“COMBO”) CONTROLS - SHARED
         ========================================= */
:is(.distance-combo, .time-combo, .pace-combo) {
  display: flex;
  align-items: center;
  border: 1px solid var(--pc-accent);
  border-radius: var(--pc-radius-lg);
  overflow: hidden;
  background: var(--pc-bg);
  width: 100%;
  min-height: 40px;
}

:is(.distance-combo, .time-combo, .pace-combo) input,
:is(.distance-combo, .time-combo, .pace-combo) select {
  border: none;
  border-radius: 0;
  background: transparent;
  outline: none;
  padding: var(--pc-pad-sm) 0.6rem;
  min-width: 0;
  flex: 1 1 0;
}

:is(.distance-combo, .time-combo, .pace-combo) > * + * {
  --pc-sep-image: linear-gradient(var(--pc-accent), var(--pc-accent));
  --pc-sep-pos: left center;
  --pc-sep-size: 1px calc(100% - 12px);
  --pc-sep-repeat: no-repeat;
  border-left: none;
  position: relative;
}

:is(.distance-combo, .time-combo, .pace-combo) > input {
  background-image: var(--pc-sep-image, none);
  background-position: var(--pc-sep-pos, left center);
  background-size: var(--pc-sep-size, 0 0);
  background-repeat: var(--pc-sep-repeat, no-repeat);
}

:is(.distance-combo, .time-combo) > select,
:is(.pace-combo) > select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--pc-bg);
  background-image: var(--pc-sep-image, none), var(--pc-chevron);
  background-position: var(--pc-sep-pos, left center), right 0.8rem center;
  background-size: var(--pc-sep-size, 0 0), 12px;
  background-repeat: var(--pc-sep-repeat, no-repeat), no-repeat;
  padding-right: 2rem;
  cursor: pointer;
  min-width: 0;
}

/* =========================================
         CAPSULE VARIANTS
         ========================================= */
.distance-combo {
  max-width: 240px;
}
.distance-combo input {
  flex: 2 1 0;
  text-align: right;
}
.distance-combo select {
  flex: 1 1 0;
}

.time-combo {
  width: 100%;
  max-width: none;
  padding: 0 0.5rem;
  justify-content: space-between;
}
.time-combo input {
  flex: 1 1 0;
  text-align: center;
}

.pace-combo {
  width: 100%;
  max-width: none;
  padding: 0 0.5rem;
  justify-content: space-between;
}
.pace-combo input {
  flex: 1 1 0;
  text-align: center;
}
.pace-combo select {
  flex: 1 1 0;
  min-width: 0;
}

/* =========================================
         UI DIVIDERS
         ========================================= */
.or-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  margin-bottom: 3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--pc-text-muted);
}
.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--pc-card-border);
}

hr {
  border: none;
  height: 1px;
  background-color: #eee;
  margin: 1.5rem;
}

/* =========================================
         BUTTONS
         ========================================= */
.pace-calculator .button-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  margin-top: 3rem;
}

.pace-calculator .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 100px;
  padding: clamp(12px, 2.5vw, 16px) clamp(16px, 4vw, 24px);
  font-size: clamp(14px, 2.8vw, 16px);
  line-height: 1;
  min-height: clamp(40px, 7vw, 52px);
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  opacity: 1;
  cursor: pointer;
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s;
}

.pace-calculator .btn-calc {
  background-color: #ffd86b;
  border: none;
  color: #000;
}
.pace-calculator .btn-reset {
  background-color: #fff;
  border: 1.5px solid #000;
  color: #000;
}

/* =========================================
         RESULTS
         ========================================= */
.result-section,
.result-wrapper {
  margin-top: 2rem;
  text-align: center;
}

.result-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.result-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.result-heading::before,
.result-heading::after {
  content: "";
  flex: 1;
  height: 2px;
  background-color: #000;
  max-width: 80px;
}
.result-heading span {
  font-family: var(--pc-font, "Inter", sans-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
}

.result-display {
  text-align: center;
  margin-top: 0.5rem;
}

.result-time {
  display: inline-block;
  font-family: var(--pc-font, "Inter", sans-serif);
  font-weight: 800;
  font-size: clamp(28px, 7.5vw, 56px);
  line-height: 1.05;
  color: var(--pc-accent);
}

/* Remove legacy “pill/alert” result styling if present */
.calculator-result .alert,
.alert.alert-info,
.result-pill {
  all: unset;
  display: initial;
}

/* =========================================
         ACCESSIBILITY & INPUT NICETIES
         ========================================= */
:is(.distance-combo, .time-combo, .pace-combo)
  :is(input, select):focus-visible {
  outline: 2px solid rgba(40, 162, 111, 0.25);
  outline-offset: 2px;
}

input[type="number"] {
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Standalone selects (not inside capsules) */
.pace-calculator select {
  border: 1px solid var(--pc-accent);
  border-radius: var(--pc-radius-lg);
  padding: var(--pc-pad-sm) 2rem var(--pc-pad-sm) 0.8rem;
  background: var(--pc-bg) var(--pc-chevron) no-repeat right 0.8rem center;
  background-size: 12px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

/* Ensure capsule selects keep capsule integration */
:is(.distance-combo, .time-combo, .pace-combo) select {
  border: none;
  border-radius: 0;
}

/* =========================================
         FIXED HERO OVERLAY
         ========================================= */
.page-workspace {
  position: relative;
}

.pc-hero {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--pc-hero-height);
  background: var(--pc-hero-bg);
  z-index: 0;
  pointer-events: none;
}

.pc-content {
  position: relative;
  z-index: 1;
}

/* =========================================
         SHARE SECTION
         ========================================= */
.share-section {
  margin: 3rem 0;
}

.share-section .share-heading {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 32px;
  line-height: 100%;
  letter-spacing: 0px;
  vertical-align: middle;
  margin: 0 0 1.5rem 0;
  text-align: left;
}

.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: flex-start;
}

.share-section .share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.2rem 3rem;
  border: 2px solid #000;
  border-radius: 999px;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 1.25rem;
  color: #000;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.share-section .share-btn .icon {
  width: 1.4rem;
  height: 1.4rem;
  display: block;
}

.share-section .share-btn:hover {
  background-color: #000;
  color: #fff;
}
.share-section .share-btn:hover .icon {
  filter: invert(1);
}

/* =========================================
         LOGO VISIBILITY & CONTAINER
         ========================================= */
.logo {
  display: inline-block;
}
.logo-mobile {
  display: none;
}

.logo-container {
  display: flex;
  justify-content: left;
  align-items: center;
  padding: 1rem 0;
}

/* =========================================
         RESPONSIVE: ≤ 992px IMAGE MAX
         ========================================= */
@media screen and (max-width: 992px) {
  .logo-container .logo-mobile img {
    max-width: 320px;
    height: auto;
    display: block;
  }
}

/* =========================================
         RESPONSIVE: ≤ 768px LOGO SWITCH
         ========================================= */
@media (max-width: 768px) {
  .logo {
    display: none;
  }
  .logo-mobile {
    display: inline-block;
  }
}

/* =========================================
         RESPONSIVE: ≤ 640px GENERAL TWEAKS
         ========================================= */
@media (max-width: 640px) {
  .pace-wrapper {
    max-width: 100%;
    margin: 1.25rem auto 8rem;
    padding: 0 1rem;
  }

  .pace-title {
    font-size: clamp(20px, 4.5vw, 24px);
    line-height: 1.2;
    margin-bottom: 0.25rem;
  }

  .section-label {
    font-size: clamp(18px, 4.2vw, 22px);
  }

  .pace-calculator {
    padding: 1rem;
    border-radius: 12px;
  }

  .distance-row,
  .time-row,
  .pace-row {
    flex-direction: column;
    gap: var(--pc-gap-md);
  }

  :is(.distance-combo, .time-combo, .pace-combo) {
    width: 100%;
    min-height: 44px;
  }
  :is(.distance-combo, .time-combo, .pace-combo) :is(input, select) {
    padding: 0.6rem 0.65rem;
    font-size: 16px;
    line-height: 1.1;
  }

  .distance-combo {
    max-width: none;
  }

  .or-divider {
    margin-top: 1.25rem;
    margin-bottom: 2rem;
  }

  .share-buttons {
    gap: 0.75rem;
  }
  .share-section .share-btn {
    width: 100%;
    justify-content: center;
    padding: 1rem 1.25rem;
    font-size: 1.05rem;
    border-width: 1.5px;
  }

  .result-heading::before,
  .result-heading::after {
    max-width: 56px;
  }

  /* Tooltip override to prevent overflow */
  .btn-info::after {
    left: auto;
    right: 0.5rem;
    transform: none;
    min-width: 0;
    max-width: calc(100vw - 1rem);
    white-space: normal;
    word-break: break-word;
  }
  .btn-info::before {
    left: auto;
    right: 1.2rem;
  }
}

/* =========================================
         RESPONSIVE: ≤ 480px SMALL PHONES
         ========================================= */
@media (max-width: 480px) {
  .pace-calculator .button-row {
    flex-direction: column;
    align-items: stretch;
  }
  .pace-calculator .btn {
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px;
  }

  .result-time {
    font-size: clamp(24px, 8vw, 44px);
  }
}

/* =========================================
         RESPONSIVE: ≥ 481px BUTTON ROW
         ========================================= */
@media (min-width: 481px) {
  .pace-calculator .button-row {
    flex-direction: row;
  }
}

/* =========================================
         RESPONSIVE: WIDER SCREENS ≥ 768px
         ========================================= */
@media (min-width: 768px) {
  .share-section {
    margin-top: 16rem;
  }
}

/* =========================================
         INTERACTION & ENVIRONMENT QUERIES
         ========================================= */
@media (pointer: coarse) {
  .btn-info {
    -webkit-tap-highlight-color: transparent;
  }
  .btn-info:active {
    opacity: 0.9;
  }
  .pace-calculator select {
    min-height: 44px;
  }
}

@media (max-height: 420px) and (orientation: landscape) {
  :root {
    --pc-hero-height: 360px;
  }
  .pace-wrapper {
    margin-bottom: 6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
  .pace-calculator .btn {
    transition: none !important;
  }
}

@supports (padding: max(0px)) {
  .pace-wrapper,
  .share-section,
  .content-body {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
}

/* Optional global safety: stops any horizontal gutter from any source */
html,
body {
  overflow-x: clip;
}

/* --- TOOLTIP: reset base --- */
.btn-info {
  position: relative; /* ensure containing block */
}

.btn-info::before,
.btn-info::after {
  display: none; /* not in layout until shown */
  content: "";
}

/* --- TOOLTIP: visible state --- */
.btn-info:hover::after,
.btn-info:focus::after,
.btn-info.active::after {
  display: block;
  content: attr(data-tooltip);
  position: absolute;
  bottom: 120%;
  right: 0; /* anchor to button’s right edge */
  transform: translateX(-8px); /* nudge left, away from edge */
  background: #000;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.25;
  padding: 8px 10px;
  border-radius: 8px;

  /* size behavior: natural width but capped to viewport */
  width: max-content;
  max-width: min(260px, calc(100vw - 24px));
  white-space: normal;
  overflow-wrap: anywhere; /* prevent single-letter stacking */
  word-break: normal;
  z-index: 10;
}

.btn-info:hover::before,
.btn-info:focus::before,
.btn-info.active::before {
  display: block;
  content: "";
  position: absolute;
  bottom: calc(120% - 2px);
  right: 14px; /* arrow near the button */
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-top-color: #000; /* little triangle */
  transform: translateY(2px);
  z-index: 10;
}

/* --- Mobile safeguards --- */
@media (max-width: 640px) {
  .btn-info:hover::after,
  .btn-info:focus::after,
  .btn-info.active::after {
    /* ensure we never push past the left gutter */
    left: auto; /* keep right-anchored */
    right: 0;
    transform: translateX(-8px);
    max-width: calc(100vw - 20px); /* safe viewport cap */
  }
  .btn-info:hover::before,
  .btn-info:focus::before,
  .btn-info.active::before {
    right: 14px;
  }
}


@media (max-width: 768px) {
  .logo-container {
    justify-content: center;
    padding: 4.5rem 1rem; 
  }

  .logo-mobile img {
    max-width: 240px;
    height: auto;
  }
}