/*
 * Dictionary Flowchart — standalone styles.
 *
 * This app is self-contained: it does not import the site's Sass or inherit
 * its layout. The tokens below are copied from the site theme
 * (_sass/_variables.scss) so the page looks like it belongs, while staying
 * portable enough to lift out into a PWA or packaged app later.
 *
 * If the site's palette changes, these do not follow automatically.
 */

:root {
  --font-sans: -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto",
               "Segoe UI", "Helvetica Neue", "Lucida Grande", Arial, sans-serif;

  --color-bg: #fff;
  --color-text: #494e52;        /* $text-color / $dark-gray */
  --color-text-muted: #7a8288;  /* $gray */
  --color-text-faint: #9ba1a6;
  --color-border: #dfe2e4;
  --color-border-faint: #f2f3f3;/* $lighter-gray */
  --color-accent: #52adc8;      /* $info-color — the site's link colour */
  --color-surface: #fafafa;

  --header-h: 3.5rem;
  --tabs-h: 2.75rem;
  --radius: 4px;
  --panel-gap: 1px;

  /* Layout breakpoint, matching the theme's $large. */
  --bp-wide: 925px;

  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  background: var(--color-bg);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  /* Fill the viewport exactly so the two panels scroll independently. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- header */

.app-header {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  padding-top: env(safe-area-inset-top, 0px);
}

.app-header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
}

.app-header__title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header__switcher { margin-left: auto; flex: 0 0 auto; }

/* --------------------------------------------------------------- controls */

.select,
.search {
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  max-width: 100%;
}

.search { flex: 1 1 auto; min-width: 0; }
.select { flex: 0 0 auto; }
.select--sort { max-width: 9.5rem; }

.search:focus,
.select:focus,
.btn:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

.btn {
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  flex: 0 0 auto;
}

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

/* ------------------------------------------------------------------ tabs */
/* Only used on narrow screens; the wide layout shows both panels at once. */

.panel-tabs {
  flex: 0 0 auto;
  display: flex;
  height: var(--tabs-h);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.panel-tabs__btn {
  flex: 1 1 50%;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.panel-tabs__btn.is-active {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

/* ---------------------------------------------------------------- panels */

.app-body {
  flex: 1 1 auto;
  min-height: 0;          /* lets children scroll instead of stretching body */
  display: flex;
  background: var(--color-border-faint);
  gap: var(--panel-gap);
}

.panel {
  background: var(--color-bg);
  min-height: 0;
  min-width: 0;
  flex-direction: column;
  display: none;          /* narrow default: one panel at a time */
}

.panel.is-active { display: flex; }

.panel__toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--color-border-faint);
}

.panel__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.entry-list { list-style: none; margin: 0; padding: 0; }

.flowchart-stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* ----------------------------------------------------------------- trail */

.trail {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------- legend */

.legend {
  flex: 0 0 auto;
  display: flex;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--color-border-faint);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.legend__item { display: inline-flex; align-items: center; gap: 0.4rem; }

.legend__line {
  display: inline-block;
  width: 1.5rem;
  height: 0;
  border-top-width: 2px;
  border-top-color: var(--color-text-faint);
}

.legend__line--solid { border-top-style: solid; }
.legend__line--dashed { border-top-style: dashed; }

/* ----------------------------------------------------------- placeholder */
/* Temporary scaffolding — removed as steps 3 and 4 land. */

.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 8rem;
  padding: 1.5rem;
  color: var(--color-text-faint);
  font-size: 0.875rem;
  font-style: italic;
  text-align: center;
}

.placeholder p { margin: 0; }

/* ------------------------------------------------------------ wide layout */

@media (min-width: 925px) {
  html { font-size: 18px; }

  .panel-tabs { display: none; }

  /* Both panels visible; the .is-active class stops mattering here. */
  .panel { display: flex; }
  .panel--dictionary { flex: 0 0 22rem; }
  .panel--flowchart { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
