/* Browser reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
    line-height: 1.15;
    /* -webkit-text-size-adjust: 100%; */
}

/* Classic Slide Rule Color Palette */
:root {
  --ivory: #ffffff; /* Primary background (pure white) */
  --parchment: #f8f8f8; /* Secondary background (very light grey) */
  --inner-dial: #f0f0f0; /* Darker inner dial background */
  --red: #B22222; /* Accent color (firebrick) */
  --dark-red: #8B0000; /* Darker accent (darkred) */
  --grey: #777777; /* Secondary accent */
  --charcoal: #333333; /* Text color */
  --light-grey: #e8e8e8; /* Active state */
  --border-grey: #dddddd; /* Border color (lighter) */
  --shadow: rgba(0,0,0,0.1);
}

body {
  background-color: var(--ivory);
  color: var(--charcoal);
  font-family: "Merriweather", serif;
}

.page {
  display: flex;
  flex-wrap: wrap;
  min-width: 150px;
  padding: 20px;
  background-color: var(--ivory);
  box-shadow: 0 2px 5px var(--shadow);
  border-radius: 4px;
}

.section {
  width: 100%;
  min-height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 15px;
  padding: 5px;
  position: relative;
}

.container {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  background-color: var(--ivory);
  border-radius: 4px;
  padding: 10px 5px;
}

.controls, .info, .powers {
  background-color: var(--ivory);
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 15px;
  border: 1px solid var(--border-grey);
  box-shadow: 0 1px 2px var(--shadow);
  width: 100%;
}

.menu {
  /* background-color: #5995DA; */
  display: false;
  visibility: none;
}

.dial {
  height: 90vmin;
  width: 100%;
  min-height: 150px;
  background-color: var(--ivory);
  border-radius: 4px;
  border: 1px solid var(--border-grey);
  box-shadow: 0 2px 4px var(--shadow);
  padding: 5px;
  margin-bottom: 15px;
  /* Prevent text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  cursor: pointer;
}

.extra { 
  /* background-color: #EAEDF0; */
  align-content: flex-start;
} 
.info {
  /* background-color: #EAEDF0; */
}
.section > div, button {
  margin: 10px;
}
.powers {
  /* background-color: #F5CF8E; */
}
.text {
  color: #333;
  width: 100%;
  padding: 5px;
  /* background-color: #F09A9D; */
  display: block;
  height: auto;
  font-size: 0.8em;
}

/* Reading display */
.reading-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.reading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 5px;
  flex: 1;
  min-width: 80px;
}

.reading-label {
  font-size: 0.85em;
  font-weight: bold;
  text-align: center;
  margin-bottom: 5px;
  color: var(--red);
  width: 100%;
}

.reading {
  font-family: "Merriweather", serif;
  padding: 8px;
  font-size: 1em;
  letter-spacing: 0.05em;
  font-variant-numeric: tabular-nums; /* Ensures fixed-width numbers for alignment */
  border-radius: 4px;
  background-color: var(--ivory);
  border: 1px solid var(--border-grey);
  width: 100%;
  text-align: center;
  box-shadow: inset 0 1px 2px var(--shadow);
  color: var(--charcoal);
}

#power {
  text-align: center;
  font-weight: bold;
}

/* Classic button styling */
button {
  padding: 8px 12px;
  border-radius: 4px;
  background-color: var(--parchment);
  border: 1px solid var(--border-grey);
  color: var(--charcoal);
  font-size: 0.9em;
  font-family: "Merriweather", serif;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px var(--shadow);
}

button:hover {
  background-color: var(--light-grey);
  border-color: var(--grey);
}

button:active, button.active {
  background-color: var(--light-grey);
  border-color: var(--red);
  box-shadow: inset 0 1px 3px var(--shadow);
  transform: translateY(1px);
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--grey);
}

/* Control group and fine mode toggle */
.control-group {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

button.fine-toggle, button.drag-toggle {
  background-color: var(--parchment);
  border-color: var(--grey);
  position: relative;
  min-width: 120px;
}

button.fine-toggle.active, button.drag-toggle.active {
  background-color: var(--light-grey);
  border-color: var(--red);
  color: var(--charcoal);
}

/* Scale selector styling */
.scale-selector {
  display: flex;
  align-items: center;
  margin-left: 20px;
}

.scale-selector label {
  margin-right: 10px;
  font-size: 0.9em;
  font-weight: bold;
  color: var(--charcoal);
}

#scaleSelect {
  padding: 8px 12px;
  border-radius: 4px;
  background-color: var(--parchment);
  border: 1px solid var(--border-grey);
  color: var(--charcoal);
  font-size: 0.9em;
  font-family: "Merriweather", serif;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px var(--shadow);
  min-width: 140px;
}

#scaleSelect:hover {
  background-color: var(--light-grey);
  border-color: var(--grey);
}

#scaleSelect:focus {
  outline: none;
  box-shadow: 0 0 0 1px var(--grey);
}

/* Power group and buttons */
.power-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  width: 100%;
}

button.power {
  min-width: 40px;
  padding: 5px 8px;
  font-weight: bold;
  border-radius: 4px;
  background-color: var(--parchment);
  margin: 0 5px;
}

#power {
  margin: 0 10px;
  width: 60px;
}

/* mobile styles */
@media only screen and (max-width: 400px) {
  .section.info,
  .section.controls,
  .section.powers {
    padding: 8px 5px;
  }

  .reading-group {
    flex-direction: column;
    align-items: center;
  }

  .reading-container {
    width: 100%;
    align-items: center;
    margin-bottom: 15px;
  }

  .reading-label {
    margin-bottom: 8px;
  }

  .reading {
    width: 100%;
    max-width: 200px;
  }

  .power-group {
    flex-wrap: wrap;
    justify-content: center;
  }

  .power-group button,
  .power-group input {
    margin: 5px;
  }

  button {
    width: 100%;
    max-width: 200px;
    margin: 5px 0;
  }

  button.power {
    min-width: 45px;
    margin: 4px;
  }

  .power-group {
    width: auto;
    margin: 0 auto;
    max-width: 280px;
  }

  .control-group {
    flex-direction: column;
    align-items: center;
  }

  button.fine-toggle, button.drag-toggle {
    min-width: 100%;
    margin-bottom: 8px;
  }

  .scale-selector {
    margin-left: 0;
    margin-top: 15px;
    width: 100%;
    justify-content: center;
  }

  #scaleSelect {
    flex: 1;
    max-width: 200px;
  }
}

/* tablet styles */
@media only screen and (min-width: 401px) and (max-width: 960px) {
  .container.extra {
    display: flex;
    flex-wrap: wrap;
  }

  .section.info,
  .section.controls,
  .section.powers {
    width: 100%;
  }

  .reading-group,
  .control-group {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
  }

  .power-group {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    width: auto;
    margin: 0 auto;
  }

  .power-group button.power {
    min-width: 36px;
    margin: 0 3px;
  }

  #power {
    margin: 0 6px;
    width: 50px;
  }

  .reading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 5px;
    flex: 1;
  }

  .reading {
    min-width: 70px;
    max-width: 100px;
    width: 100%;
  }

  button {
    min-width: auto;
    padding: 8px 10px;
    margin: 0 8px;
  }

  button#setHand, button#setFace {
    margin: 0 5px;
    flex: 0 1 auto;
  }

  button#fineToggle, button#dragToggle {
    min-width: 110px;
    margin: 0 5px;
  }

  .scale-selector {
    margin-left: 10px;
  }

  #scaleSelect {
    min-width: 120px;
    padding: 8px;
  }
}

/* Desktop styles */
@media only screen and (min-width: 961px) {
  .page {
    margin: 0 auto;
    max-width: 1200px;
    display: flex;
    flex-direction: row;
  }

  .dial {
    height: 90vmin;
    max-height: 700px;
    width: 50%;
  }

  .extra {
    width: 50%;
    max-width: 600px;
    padding-left: 20px;
  }

  .reading-group {
    justify-content: space-between;
    align-items: flex-end;
  }

  .reading-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  button {
    flex: 0 1 auto;
    margin: 0 10px;
  }

  button#setHand, button#setFace {
    min-width: 100px;
  }

  .reading {
    min-width: 80px;
    max-width: 120px;
    width: 100%;
  }
}





/* Vintage slide rule styling */
svg {
  stroke: var(--charcoal);
  font-family: "Merriweather", serif;
}

.tick {
  stroke-width: 1;
  fill: var(--charcoal);
}

.label {
  font-size: 20px;
  font-weight: 100;
  font-style: italic;
  fill: var(--charcoal);
  /* Prevent text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.minor-label, .half-label, .decimal-minor-label, .teen-minor-label {
  font-size: 10px;
  fill: var(--charcoal);
}

.origin-label {
  font-size: 30px;
  fill: var(--charcoal);
  font-weight: 400;
}

.special-label {
  font-size: 10px;
  fill: var(--red);
  font-weight: bold;
}

/* Special styling for the transition point on ST scale */
.transition-mark {
  stroke: var(--red);
  stroke-width: 2;
  stroke-dasharray: 2,2;
}

.edge {
  stroke-width: 1;
  stroke: var(--charcoal);
  fill: GhostWhite;
  z-order: -2;
  filter: drop-shadow(0px 1px 1px var(--shadow));
}

.indicator {
  stroke-width: 1.5;
  stroke: var(--red);
  opacity: 0.85;
  z-order: 3;
}

.animate {
  transition: transform 0.2s ease-in;
}

.hand {
  stroke-width: 1.5;
  stroke: var(--red);
  opacity: 0.85;
  z-order: 5;
}

.hand-overlay {
  opacity: 1;
  stroke: var(--red);
  fill: var(--red);
  stroke-linecap: round;
  z-order: 6;
}

/* Indicator style for drag mode */
/* Keep the needle looking the same as in scrub mode */

/* Make the overlay slightly larger but without glow */
.drag-mode .hand-overlay {
  r: 6;
}

/* Visual cue for drag mode - subtle change to the edge */
.drag-mode .edge {
  stroke-dasharray: none;
  stroke-width: 1.5;
}

.hand-back {
  stroke-width: 2;
  opacity: 1;
  stroke: var(--red);
  fill: var(--red);
  stroke-linecap: round;
  z-order: 7;
}

#main {
  height: 100vh;
  width: 100vw;
  padding: 0 auto;
}

#nums {
  font-family: monospace;
  position: absolute;
  right: 0;
  top: 0;
}

/* Text styling */
.text {
  padding: 15px;
  background-color: var(--ivory);
  border: 1px solid var(--border-grey);
  border-radius: 4px;
  box-shadow: 0 1px 2px var(--shadow);
  margin-bottom: 15px;
}

.text p {
  margin-bottom: 10px;
  line-height: 1.5;
  color: var(--charcoal);
}

.text ul {
  margin-bottom: 10px;
  margin-left: 20px;
  line-height: 1.5;
  color: var(--charcoal);
}

.text li {
  margin-bottom: 5px;
}

.text strong {
  color: var(--red);
  font-weight: bold;
}

#description {
  color: var(--charcoal);
  font-family: "Merriweather", serif;
}

.history-chevron {
  stroke: var(--grey);
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0px 1px 1px var(--shadow));
}

.history-marker {
  opacity: 0;
  transition: opacity 0.2s ease-in;
}

