/* start light mode styling */
:root {
  --text: darkslategrey;
  --border: lightgrey;
  --accent: teal;
  --bg: #dce3e1;
  --gradientTop: white;
  --gradientBottom: rgb(240, 248, 255, 0.8);
  --bg-pan-speed: 18s;
}

header {
  background: linear-gradient(135deg, #b8ece6, #d7f4ff);
}
/* end light mode styling */

/* start dark mode styling */
@media (prefers-color-scheme: dark) {
  :root {
    --text: white;
    --border: #5a7678;
    --accent: #74c365;
    --bg: rgb(0, 60, 60, 0.8);
    --gradientBottom: rgb(0, 50, 60);
    --gradientTop: darkslategrey;
  }

  a:link {
    color: lightblue;
  }

  header {
    background: linear-gradient(135deg, #174950, #112f3a);
  }
}
/* end dark mode styling */

.animated-bg {
  --bg-image: linear-gradient(135deg, #b8ece6, #d7f4ff);
  --tint-color: rgba(0, 120, 120, 0.36);
  --tint-color-hover: rgba(0, 120, 120, 0);
  --tint-strength: 1;
  --tint-strength-hover: 0.2;
  --tint-fade-in: 0.5s;
  --tint-fade-out: 0.3s;
  position: relative;
  overflow: hidden;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.animated-bg > * {
  position: relative;
  z-index: 1;
}

.animated-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--tint-strength);
  background:
    linear-gradient(var(--tint-color), var(--tint-color)),
    repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.22) 0 14px, rgba(255, 255, 255, 0.03) 14px 28px);
  transition: opacity var(--tint-fade-in) ease, background var(--tint-fade-in) ease;
}

.animated-bg:hover::before,
.animated-bg:focus-within::before {
  opacity: var(--tint-strength-hover);
  background:
    linear-gradient(var(--tint-color-hover), var(--tint-color-hover)),
    repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.08) 0 14px, rgba(255, 255, 255, 0) 14px 28px);
  transition-duration: var(--tint-fade-out), var(--tint-fade-out);
}

.animated-bg::after {
  content: '';
  position: absolute;
  inset: -10%;
  pointer-events: none;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.2), transparent 40%);
  mix-blend-mode: screen;
  animation: bg-pan var(--bg-pan-speed) linear infinite;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 10px;
  font-family: 'MS PGothic', sans-serif;
  color: var(--text);
  background-color: var(--gradientTop);
  background-image: linear-gradient(30deg, var(--bg) 12%, transparent 12.5%, transparent 87%, var(--bg) 87.5%, var(--bg)),
    linear-gradient(150deg, var(--bg) 12%, transparent 12.5%, transparent 87%, var(--bg) 87.5%, var(--bg)),
    linear-gradient(30deg, var(--bg) 12%, transparent 12.5%, transparent 87%, var(--bg) 87.5%, var(--bg)),
    linear-gradient(150deg, var(--bg) 12%, transparent 12.5%, transparent 87%, var(--bg) 87.5%, var(--bg)),
    linear-gradient(60deg, var(--bg) 25%, transparent 25.5%, transparent 75%, var(--bg) 75%, var(--bg)),
    linear-gradient(60deg, var(--bg) 25%, transparent 25.5%, transparent 75%, var(--bg) 75%, var(--bg));
  background-size: 20px 35px;
  background-position: 0 0, 0 0, 10px 18px, 10px 18px, 0 0, 10px 18px;
  animation: body-bg-scroll-top-right 2.27489867876787589430s linear infinite;
}

.container {
  max-width: 80rem;
  margin: 5vw auto 12px auto;
  border: 6px ridge var(--border);
  outline: 3px solid var(--gradientTop);
  outline-offset: 4px;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  padding: 5px;
  gap: 8px;
  background-color: var(--gradientBottom);
  background-image: repeating-radial-gradient(circle at 0 0, transparent 0, var(--gradientBottom) 9px),
    repeating-linear-gradient(var(--bg), var(--bg));
}

.small {
  flex: 1 1 12rem;
}

.large {
  flex: 3 1 30rem;
}

.full {
  flex: 1 1 100%;
}

.half {
  flex: 1 1 24rem;
}

header {
  background-size: cover;
  background-position: center;
  width: 100%;
  min-height: 400px;
  border: 2px ridge var(--border);
  border-radius: 5px;
  position: relative;
}

header span {
  font-size: clamp(1.2rem, 4vw, 2rem);
  position: absolute;
  bottom: 0;
  right: 10px;
  margin: 10px;
  font-weight: bold;
  text-align: right;
  text-shadow: 1px 1px var(--text), -1px 1px var(--text), 1px -1px var(--accent), -1px -1px var(--accent);
  color: var(--gradientTop);
}

nav,
section {
  border: 2px ridge var(--border);
  border-radius: 5px;
  padding: 8px;
  background: linear-gradient(var(--gradientTop), var(--gradientBottom));
}

nav div {
  text-align: center;
  font-size: 1.25rem;
  margin: 5px 5px 10px 5px;
}

nav a,
button {
  display: block;
  margin: 5px;
  background: linear-gradient(to right, var(--bg), var(--gradientBottom));
  border-radius: 5px;
  padding: 8px 10px;
  text-decoration: none;
  border: 2px ridge var(--border);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}

nav a:link,
nav a:visited {
  color: var(--text);
}

nav a:hover,
nav a:focus,
button:hover,
button:focus {
  background: linear-gradient(to right, var(--bg), var(--gradientBottom), var(--gradientTop));
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin: 5px;
  line-height: 1.3;
}

h1 {
  font-size: 1.4rem;
  letter-spacing: 2px;
  font-weight: normal;
  text-align: center;
  border-bottom: 2px ridge var(--border);
  padding-bottom: 5px;
}

h2 {
  font-size: 1.25rem;
  font-weight: normal;
  text-align: center;
}

h4 {
  font-size: 1rem;
  color: var(--accent);
  padding-left: 12px;
}

a:hover,
a:focus {
  font-style: italic;
}

a:visited {
  color: var(--accent);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
}

input {
  width: 100%;
  border: 2px ridge var(--border);
  border-radius: 5px;
  padding: 8px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: color-mix(in srgb, var(--gradientTop) 70%, var(--gradientBottom));
}

.meta {
  font-size: 0.9rem;
  margin-top: 10px;
}

.grid-wrap {
  margin-top: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.grid-label.cols,
.grid {
  min-width: 560px;
  display: grid;
  grid-template-columns: repeat(6, minmax(80px, 1fr));
  gap: 10px;
}

.grid-label.cols {
  margin-bottom: 6px;
}

.grid {
  grid-template-rows: repeat(3, minmax(84px, auto));
  margin-top: 4px;
}

body.compact-layout #predictor .grid-wrap {
  overflow-x: visible;
}

body.compact-layout #predictor .grid-label.cols,
body.compact-layout #predictor .grid {
  min-width: 0;
  width: 100%;
  gap: 4px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

body.compact-layout #predictor .grid {
  grid-template-rows: repeat(3, minmax(58px, auto));
}

body.compact-layout #predictor .tile {
  padding: 4px 3px;
  min-height: 58px;
  gap: 2px;
  font-size: 0.68rem;
}

body.compact-layout #predictor .tile .index {
  font-size: 0.6rem;
}

body.compact-layout #predictor .tile .value {
  font-size: 0.86rem;
}

body.compact-layout #predictor h1 {
  letter-spacing: 1px;
}

.mode-chooser {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  display: grid;
  place-items: center;
  z-index: 9999;
  padding: 10px;
}

.mode-chooser[hidden] {
  display: none;
}

.mode-chooser-card {
  width: min(420px, 100%);
  border: 3px ridge var(--border);
  border-radius: 10px;
  background: linear-gradient(var(--gradientTop), var(--gradientBottom));
  padding: 12px;
  text-align: center;
}

.mode-chooser-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-chooser-actions button {
  margin: 0;
}

.tile {
  border: 2px ridge var(--border);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  min-height: 78px;
  display: grid;
  align-content: center;
  gap: 4px;
  font-size: 0.85rem;
}

.tile .index {
  font-size: 0.75rem;
}

.tile .value {
  font-size: 1rem;
  font-weight: bold;
}

.air { background: #d4dde0; }
.parsnips { background: #b9d9bc; }
.cranberries { background: #e4bbca; }
.grapes { background: #c4c1e8; }
.corn { background: #e6ddb1; }

@media (prefers-color-scheme: dark) {
  .air { background: #2e3a3e; }
  .parsnips { background: #2f4c34; }
  .cranberries { background: #5a2f3d; }
  .grapes { background: #453a67; }
  .corn { background: #5f5632; }
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 10px;
  font-size: 0.88rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 2px ridge var(--border);
  border-radius: 6px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

footer {
  text-align: center;
  margin-bottom: 5vw;
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .sidebar {
    flex: 1 1 100%;
    order: 1;
  }

  .large,
  .half,
  .small {
    flex: 1 1 100%;
  }

  .controls {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 600px) {
  body {
    padding: 6px;
  }

  .container {
    margin-top: 8px;
    border-width: 4px;
    outline-width: 2px;
    padding: 4px;
  }

  header {
    min-height: 100px;
  }

  header span {
    right: 4px;
    margin: 6px;
  }

  nav,
  section {
    padding: 6px;
  }

  .grid-label.cols,
  .grid {
    min-width: 480px;
    gap: 8px;
    grid-template-columns: repeat(6, minmax(70px, 1fr));
  }

  body.compact-layout #predictor .grid-label.cols,
  body.compact-layout #predictor .grid {
    min-width: 0;
    gap: 3px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .mode-chooser-actions {
    grid-template-columns: 1fr;
  }
}

@keyframes bg-pan {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(12%, -12%, 0);
  }
}

@keyframes body-bg-scroll-top-right {
  from {
    background-position: 0 0, 0 0, 10px 18px, 10px 18px, 0 0, 10px 18px;
  }
  to {
    background-position: 20px -35px, 20px -35px, 30px -17px, 30px -17px, 20px -35px, 30px -17px;
  }
}
