/*
 * Make a Neural Net styles.
 *
 * Provides the paper-like off-white background, Fanwood typography, the
 * two-column wizard grid (content on the left, toy piece on the right),
 * the breadcrumb bar, the per-step container, and the geometric button
 * styling used throughout the flow.
 *
 * Released under the BSD-3-Clause license (see LICENSE.md).
 */

:root {
  --color-bg: #f5f5f5;
  --color-btn-primary: #74748b;
  --color-btn-primary-hover: #5f5f75;
  --color-btn-secondary: #747474;
  --color-btn-secondary-hover: #606060;
  --color-text: #1a1a1a;
  --color-toy-stroke: #000000;
  --layout-width: 1000px;
  --button-radius: 4px;
}

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: "Fanwood", serif;
}

a {
  color: #5050C0;
  text-decoration: underline dotted;
}

a:hover,
a:focus {
  color: #3030C0;
  text-decoration: underline solid;
}

#app {
  width: 100%;
  max-width: var(--layout-width);
  margin: 0 auto;
  padding: 24px;
  box-sizing: border-box;
}

/* Skip link: visually hidden until focused by keyboard. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  z-index: 1000;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
  padding: 8px 16px;
  background-color: var(--color-btn-primary);
  color: #ffffff;
  border-radius: var(--button-radius);
  text-decoration: none;
}

/* Breadcrumb bar along the top allows backward navigation only. */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 16px;
  border-bottom: 1px solid #d8d8d8;
  margin-bottom: 24px;
}

.breadcrumbs .crumb {
  font-size: 14px;
  color: #6a6a6a;
  cursor: pointer;
  text-decoration: underline;
}

.breadcrumbs .crumb.hidden {
  display: none;
}

.breadcrumbs .crumb.current {
  color: var(--color-text);
  font-weight: bold;
  text-decoration: none;
}

/* Each step lives in its own container. Only the active step is shown. */
.step {
  display: none;
}

.step.active {
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 32px;
  align-items: start;
}

.step-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.step-content .title {
  font-size: 28px;
  margin: 0;
}

.step-content .body p {
  margin: 0 0 12px;
  line-height: 1.5;
}

.step-content .body p:last-child {
  margin-bottom: 0;
}

.step-content .controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.step-content .buttons {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* Toy piece lives in the right column. SVG scales with the container. */
.toy {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
  padding-right: 32px;
}

/*
 * Narrow-screen warning line. Hidden on wide screens and revealed by the
 * small-screen media query below so it sits directly above the toy piece only
 * when the viewport is too narrow for the two-column layout.
 */
.toy::before {
  content: "Heads up! This works best on a larger screen like a desktop or tablet.";
  display: none;
}

/* Stacked variant lays the toy pieces out vertically (e.g. step 2 corpus). */
.toy.stack {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 12px;
}

/* Ensure interactive elements inside the toy fill the column width. */
.toy input,
.toy button,
.toy label,
.toy details,
.toy div {
  box-sizing: border-box;
}

.toy.stack input[type="text"] {
  width: 100%;
}

/* Three side-by-side SVG columns for the step 5 context visualization. */
.context-columns {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.context-columns svg {
  flex: 1;
  height: auto;
  max-width: 120px;
}

#corpus-input {
  width: 100%;
  min-height: 260px;
  box-sizing: border-box;
  font-family: "Fanwood", serif;
  font-size: 14px;
  line-height: 1.4;
  padding: 8px;
  border: 1px solid #cfcfcf;
  border-radius: var(--button-radius);
  background-color: #ffffff;
  color: var(--color-text);
  resize: vertical;
}

.toy svg {
  width: 100%;
  height: auto;
  max-width: 360px;
}

/* Geometric buttons with slight rounding; darken on hover/focus. */
.btn {
  font-family: "Fanwood", serif;
  font-size: 16px;
  padding: 10px 16px 8px;
  border: none;
  border-radius: var(--button-radius);
  cursor: pointer;
  color: #ffffff;
  background-color: var(--color-btn-secondary);
  transition: background-color 0.15s ease;
}

.btn:hover,
.btn:focus {
  background-color: var(--color-btn-secondary-hover);
}

.btn.primary {
  background-color: var(--color-btn-primary);
}

.btn.primary:hover,
.btn.primary:focus {
  background-color: var(--color-btn-primary-hover);
}

#epoch-slider,
#training-progress {
  width: 100%;
  box-sizing: border-box;
}

#train-button {
  width: 100%;
  box-sizing: border-box;
}

#inference-input {
  flex: 1;
}

.inference-input-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

#answer-button {
  width: 100%;
  box-sizing: border-box;
}

.prompt-output {
  min-height: 1.5rem;
  color: #333333;
  font-weight: 500;
}

.answer-output {
  min-height: 1.5rem;
  color: #555555;
  font-style: italic;
}

#conclusion-circle {
  transition: fill 0.2s ease;
}

#connections-who,
#connections-moon,
#connections-armstrong {
  transition: fill 0.2s ease;
}

#connections-svg {
  max-width: 300px;
}

#structure-svg {
  max-width: 400px;
}

#structure-svg circle {
  transition: fill 0.15s ease;
}

#inference-corpus-details {
  margin-top: 16px;
}

#inference-corpus-details summary {
  cursor: pointer;
  font-size: 14px;
  color: #6a6a6a;
}

#inference-corpus {
  margin: 8px 0 0;
  padding: 12px;
  background-color: #ffffff;
  border: 1px solid #cfcfcf;
  border-radius: var(--button-radius);
  font-family: "Fanwood", serif;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 200px;
}

/*
 * Responsive layout.
 *
 * The default rules above target the desktop two-column layout (assumed ~1000px
 * wide). Below, media queries adapt for small (phone / narrow window) and large
 * screens. On narrow viewports the content / toy columns stack vertically and a
 * bold warning line is revealed above the toy piece.
 */

/* Small screens: phone or narrow window. Left becomes top, right becomes bottom. */
@media (max-width: 768px) {
  #app {
    padding: 16px;
  }

  .breadcrumbs {
    gap: 6px;
    padding: 6px 0 12px;
    margin-bottom: 16px;
  }

  .breadcrumbs .crumb {
    font-size: 13px;
  }

  .step.active {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .step-content .title {
    font-size: 24px;
  }

  .step-content .body p {
    line-height: 1.4;
  }

  .step-content .buttons {
    flex-wrap: wrap;
  }

  /* Stack the toy piece vertically and reveal the warning line above it. */
  .toy {
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
    padding-right: 0px;
  }

  .toy::before {
    display: block;
    width: 100%;
    font-weight: bold;
    text-align: center;
    color: #000000;
    border-top: 1px solid #d8d8d8;
    border-bottom: 1px solid #d8d8d8;
    margin-top: 8px;
    margin-bottom: 16px;
    padding: 12px 0;
  }

  .toy svg {
    max-width: 100%;
  }

  #connections-svg {
    max-width: 100%;
  }

  #structure-svg {
    max-width: 100%;
  }

  #corpus-input {
    min-height: 180px;
    font-size: 13px;
  }
}

/* Large screens: give the diagrams a bit more presence on big monitors. */
@media (min-width: 1400px) {
  :root {
    --layout-width: 1100px;
  }

  .toy svg {
    max-width: 440px;
  }

  #connections-svg {
    max-width: 360px;
  }

  #structure-svg {
    max-width: 480px;
  }
}

/* Footer below the steps grid with a top border. */
.footer {
  border-top: 1px solid #d8d8d8;
  margin-top: 32px;
  padding-top: 16px;
  text-align: center;
}

.footer a {
  font-size: 14px;
  color: #6a6a6a;
  text-decoration: underline;
  cursor: pointer;
}

.footer a:hover,
.footer a:focus {
  color: var(--color-text);
}

/* About dialog styling. */
#about-dialog {
  max-width: 600px;
  width: 90%;
  border-radius: var(--button-radius);
  border: 1px solid #cfcfcf;
  padding: 0;
}

#about-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.4);
}

.about-dialog-content {
  padding: 24px;
}

.about-dialog-content h2 {
  margin: 0 0 16px;
  font-size: 22px;
}

.about-dialog-body {
  line-height: 1.5;
}

.about-dialog-body p {
  margin: 0 0 12px;
}

.about-dialog-body details {
  margin-top: 8px;
}

.about-dialog-body details summary {
  cursor: pointer;
  font-size: 14px;
  color: #6a6a6a;
}

.about-dialog-body details div {
  margin-top: 8px;
}

.about-dialog-buttons {
  border-top: 1px solid #d8d8d8;
  margin-top: 16px;
  padding-top: 16px;
  text-align: center;
}
