/* Void Stranger floor hints — mobile-first (portrait) */

:root {
  --bg: #14151a;
  --surface: #1e2029;
  --surface-2: #262933;
  --border: #363a47;
  --text: #eef0f5;
  --text-dim: #a2a7b6;
  --accent: #7fd1c1;
  --accent-ink: #0c1614;
  --error: #ff9b9b;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  min-height: 100dvh;
  padding: max(1rem, env(safe-area-inset-top))
           max(1rem, env(safe-area-inset-right))
           max(1.5rem, env(safe-area-inset-bottom))
           max(1rem, env(safe-area-inset-left));
}

/* Masthead — title text with the Back button beside it (portrait) */
.app__masthead {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app__masthead .app__header {
  flex: 1 1 auto;
  min-width: 0;
}

/* Difficulty background art — a transparent PNG pinned to the right edge of the
   viewport, scaled to the window height, sitting behind all content on the dark bg */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  /* portrait: 3% buffer on left/top/right, flush to the bottom edge */
  padding: 3% 3% 0;
  background-origin: content-box;
  background-repeat: no-repeat;
  background-position: right bottom;
  background-size: contain;
  opacity: 0.5;
  transition: opacity 0.2s ease, background-image 0s;
}

body[data-mode="normal"]::before {
  background-image: url("images/normal.png");
}

body[data-mode="hard"]::before {
  background-image: url("images/hard.png");
}

@media (prefers-reduced-motion: reduce) {
  body::before {
    transition: none;
  }
}

/* Back button */
.back {
  flex: 0 0 auto;
  align-self: center; /* vertically centered next to the title in portrait */
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid var(--border);
  border-radius: 0.85rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.back:hover {
  border-color: var(--accent);
  filter: brightness(1.08);
}

.back:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.back:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.app {
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.app__panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Header */
.app__header {
  padding-top: 0.5rem;
}

.app__header h1 {
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app__subtitle {
  color: var(--text-dim);
  font-size: clamp(0.95rem, 4vw, 1.1rem);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

/* Mode toggle (Normal / Hard hint set) */
.mode {
  display: flex;
}

.mode-toggle {
  position: relative;
  display: inline-flex;
  padding: 0.25rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 0.85rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mode-toggle::before {
  content: "";
  position: absolute;
  top: 0.25rem;
  bottom: 0.25rem;
  left: 0.25rem;
  width: calc(50% - 0.25rem);
  background: var(--accent);
  border-radius: 0.6rem;
  transition: left 0.18s ease;
}

.mode-toggle[aria-pressed="true"]::before {
  left: 50%;
}

.mode-toggle__opt {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 5rem;
  text-align: center;
  padding: 0.55rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.15s ease;
}

.mode-toggle[aria-pressed="false"] .mode-toggle__opt[data-mode="normal"],
.mode-toggle[aria-pressed="true"] .mode-toggle__opt[data-mode="hard"] {
  color: var(--accent-ink);
}

.mode-toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.mode-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .mode-toggle::before,
  .mode-toggle__opt {
    transition: none;
  }
}

/* Picker */
.picker {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.picker__label {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-dim);
}

.picker__control {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.picker__select-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.picker__select-wrap::after {
  content: "";
  position: absolute;
  right: 1.1rem;
  top: 50%;
  width: 0.7rem;
  height: 0.7rem;
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.picker__select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.95rem 3rem 0.95rem 1.1rem;
  min-height: 3.4rem;
}

/* smaller text while the "— select —" placeholder is showing, so it doesn't
   get clipped in the narrow landscape column */
.picker__select--placeholder {
  font-size: 0.85rem;
  font-weight: 600;
  padding-right: 2.2rem;
}

.picker__select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Step buttons */
.picker__step {
  flex: 0 0 auto;
  width: 3.4rem;
  min-height: 3.4rem;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 0.85rem;
  cursor: pointer;
}

.picker__step:hover:not(:disabled) {
  border-color: var(--accent);
}

.picker__step:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.picker__step:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Status line */
.status {
  color: var(--text-dim);
  font-size: 0.95rem;
}

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

/* Result */
.result {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
}

.result__floor {
  background: var(--accent);
  color: var(--accent-ink);
  font-size: clamp(1.8rem, 9vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.9rem 1.2rem;
}

.result__body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.2rem 1.2rem 1.4rem;
}

.result__hint {
  font-size: clamp(1.15rem, 5vw, 1.4rem);
  line-height: 1.7;
  word-break: break-word;
  hyphens: auto;
  white-space: pre-wrap; /* preserve line breaks from the original hint text */
}

.result__image-link {
  display: block;
  border: 2px solid var(--border);
  border-radius: 0.6rem;
  overflow: hidden;
}

.result__image-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.result__image {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface-2);
}

@media (prefers-reduced-motion: no-preference) {
  .result {
    animation: rise 0.18s ease-out;
  }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Landscape — lay the panel and the result out side by side and fit the screen */
@media (orientation: landscape) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
  }

  /* Regular widescreen (≈16:9): keep the art near the right edge with a small
     3% buffer, and let it stand taller. Ultrawide screens get a larger inset. */
  body::before {
    padding: 0;
    background-origin: border-box;
    background-position: right 3% bottom 0;
    background-size: auto 88%;
  }

  /* Ultrawide (≈21:9 and wider) — keep the art off the right edge and at the
     original height, as before. Cutoff is 21/9 itself: a 16:9 monitor's browser
     viewport loses height to the toolbar/tabs and lands around 2:1, which must
     NOT count as ultrawide. */
  @media (min-aspect-ratio: 21 / 9) {
    body::before {
      background-position: right 10vw bottom 0;
      background-size: auto 69%;
    }
  }

  .app {
    flex-direction: row;
    align-items: stretch;
    gap: 1.25rem;
    max-width: 64rem;
    max-height: calc(100dvh - 2rem);
  }

  .app__panel {
    flex: 0 0 clamp(12rem, 34%, 17rem);
    gap: 1rem;
    overflow-y: auto;
    padding-right: 0.25rem;
  }

  .app__header {
    padding-top: 0;
  }

  /* landscape: Back button stacked above the title, flush with the
     same left edge as the rest of the panel content */
  .app__masthead {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 1rem;
  }

  .app__masthead .back {
    align-self: flex-start;
  }

  /* only lay out the result box once it actually has content */
  .result:not([hidden]) {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .result__floor {
    position: sticky;
    top: 0;
    flex: 0 0 auto;
  }

  .result__scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
}

/* Light mode */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #eceef3;
    --border: #d3d7e0;
    --text: #1b1d24;
    --text-dim: #5b6070;
    --accent: #1f8a76;
    --accent-ink: #ffffff;
    --error: #b42318;
  }
}
