/*
 * Johari design language tokens and styles
 */

:root {
  --cream:         #F5EDD6;
  --teal:          #4A9B8E;
  --peach:         #E8855A;
  --blush:         #D4849C;
  --mint:          #7AC4B6;
  --charcoal:      #2C2C2C;
  --border:        #2C2C2C;
  --grid:          rgba(44, 44, 44, 0.06);
  --drawer-height: 116px;
}

/* Base */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  background: var(--cream);
  color: var(--charcoal);
  font-family: 'Courier New', Courier, monospace;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Prevent content from hiding behind fixed drawer */
body {
  padding-bottom: var(--drawer-height);
}

h1 {
  font-family: Arial, 'Arial Narrow', Helvetica, sans-serif;
  font-weight: 900;
  font-stretch: condensed;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 2.5rem;
  margin: 0 0 1.5rem 0;
}

a {
  color: var(--teal);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Page content */

main.page-content {
  padding: 2rem;
}

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

/* Bottom drawer */

.bottom-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--drawer-height);
  background: var(--cream);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  align-items: center;
  padding: 0.5rem 2rem;
  gap: 0.5rem 1rem;
}

.drawer-break {
  flex-basis: 100%;
  height: 0;
}

@media (max-width: 600px) {
  .bottom-drawer {
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }
  .bottom-drawer .drawer-form {
    width: 100%;
  }
}

/* Square-bordered button — Johari box-button aesthetic */

.btn {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--charcoal);
  font-family: inherit;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.1s, color 0.1s;
}

.btn:hover {
  background: var(--charcoal);
  color: var(--cream);
  text-decoration: none;
}

/* button_to wraps in <form>, unwrap the visual */
.btn-form {
  display: inline;
  margin: 0;
  padding: 0;
}

/* Drawer form */

.drawer-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.drawer-form label {
  font-size: 0.7rem;
}

.drawer-form input[type="number"] {
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--charcoal);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.4rem;
  width: 5rem;
  outline: none;
}

.drawer-form input[type="number"]:focus {
  background: rgba(44, 44, 44, 0.05);
}

.drawer-form input[type="checkbox"] {
  accent-color: var(--teal);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.drawer-form .checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Workbook rise animation — no max-height constraint */

@keyframes workbook-rise {
  from {
    transform: translateY(2.5rem);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Single-block step entrance */
.workbook-step {
  animation: workbook-rise 0.3s ease-out both;
}

/* Per-item stagger: set --wi on each element */
.workbook-item {
  animation: workbook-rise 0.4s ease-out both;
  animation-delay: calc(var(--wi, 0) * 1s);
}

/* Intro container — column-reverse, fixed above drawer, like #results */
#workbook-intro {
  position: fixed;
  bottom: var(--drawer-height);
  left: 0;
  right: 0;
  padding: 2rem;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  max-height: calc(100vh - var(--drawer-height));
  overflow-y: auto;
  pointer-events: none;
}

#workbook-intro > * {
  pointer-events: auto;
}

#workbook-intro h1 {
  margin-bottom: 0.5rem;
}

#workbook-intro p {
  margin: 0.25rem 0;
}

#workbook-intro ul {
  margin: 0.25rem 0 0 1.2rem;
  padding: 0;
}

#workbook-intro li {
  margin: 0.15rem 0;
}

.workbook-intro__bullet::before {
  content: "– ";
  opacity: 0.5;
}

/* Results */

@keyframes float-up {
  from {
    transform: translateY(40px);
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
    max-height: 3rem;
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
  }
}

#results {
  position: fixed;
  bottom: var(--drawer-height);
  left: 0;
  right: 0;
  padding: 1rem 2rem;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  max-height: calc(100vh - var(--drawer-height) - 4rem);
  overflow-y: auto;
  pointer-events: none;
}

.result {
  pointer-events: auto;
  animation: float-up 0.5s ease-out forwards;
  overflow: hidden;
  font-size: 1.5rem;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  margin: 0;
  padding: 0.1rem 0;
}

.result--loading  { color: var(--charcoal); opacity: 0.3; animation: none; }
#results-loader:not(:only-child) { display: none; }

.result--fizz     { color: var(--teal); }
.result--buzz     { color: var(--peach); }
.result--number   { color: var(--charcoal); }

.result--fizzbuzz {
  background: linear-gradient(90deg, var(--teal), var(--peach));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

/* Links page */

#links {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}

#links li {
  border-bottom: 1px solid var(--grid);
  padding: 0.6rem 0;
  font-size: 0.9rem;
}

#qr_code_container {
  margin: 1.5rem 0;
}

#qr_code_container svg {
  display: block;
  width: 100%;
  max-width: min(300px, calc(100vw - 4rem));
  height: auto;
  border: 1px solid var(--border);
}

/* Flash */

.flash-notice {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--teal);
  margin-bottom: 1rem;
}

/* New link form */

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  margin-bottom: 0.3rem;
}

.form-field input[type="text"],
.form-field input[type="url"] {
  border: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--charcoal);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  width: 24rem;
  outline: none;
}

.form-field input:focus {
  background: rgba(44, 44, 44, 0.05);
}

/* =====================================================
   Workbook Wizard
   ===================================================== */

#workbook-wizard {
  max-width: 860px;
  margin: 0 auto;
  overflow-x: hidden;
}

#workbook-wizard h2 {
  font-family: Arial, 'Arial Narrow', Helvetica, sans-serif;
  font-weight: 900;
  font-stretch: condensed;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 1.4rem;
  color: var(--teal);
  margin: 0 0 1rem;
}
#workbook-wizard h2.h2--high { color: var(--blush); }
#workbook-wizard h2.h2--mid  { color: var(--peach); }
#workbook-wizard h2.h2--low  { color: var(--mint); }

/* Workbook intro title — fizzbuzz gradient */
#workbook-intro h1 {
  background: linear-gradient(90deg, var(--teal), var(--peach));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

/* SUDS table row zone tints */
.suds-zone--high { background: rgba(212, 132, 156, 0.18); }
.suds-zone--mid  { background: rgba(232, 133, 90,  0.14); }
.suds-zone--low  { background: rgba(122, 196, 182, 0.18); }
tr[data-controller="suds-row"]  { cursor: pointer; }
tr[data-controller="trap-row"]  { cursor: pointer; }

/* Context box — shows user's primary thought in context */
.context-box {
  background: rgba(74, 155, 142, 0.1);
  border-left: 3px solid var(--teal);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.context-box p { margin: 0.25rem 0 0; }
.context-box ul { margin: 0; padding-left: 1.25rem; }

/* Tables */
.workbook-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.workbook-table th,
.workbook-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  vertical-align: top;
  text-align: left;
}
.workbook-table th {
  background: rgba(44, 44, 44, 0.06);
  font-weight: bold;
}
.workbook-table td:first-child { width: 2.5rem; text-align: center; }

.trap-table td:first-child { width: 2.5rem; }
.trap-table td:nth-child(2) { width: 9rem; font-weight: bold; }
@media (max-width: 600px) {
  .trap-table th:nth-child(4),
  .trap-table td:nth-child(4) { display: none; }
}

/* Form fields */
.field {
  margin-bottom: 1rem;
}
.field label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.3rem;
}
.field textarea,
.field input[type="number"] {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--charcoal);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  outline: none;
  width: 100%;
}
.field textarea { min-height: 5rem; }
.field input[type="number"] { width: 6rem; }
.field textarea:focus,
.field input:focus { background: rgba(44, 44, 44, 0.05); }

/* Inline textarea in table cells */
.workbook-table textarea {
  width: 100%;
  min-height: 3rem;
  border: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.3rem;
  outline: none;
  resize: vertical;
}
.workbook-table input[type="number"] {
  width: 5rem;
  border: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.3rem;
}

/* TIPP options */
.tipp-options { margin-bottom: 1rem; }
.tipp-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(44, 44, 44, 0.15);
  cursor: pointer;
}
.tipp-option:last-child { border-bottom: none; }
.tipp-option input { margin-top: 0.3rem; flex-shrink: 0; }
.tipp-option dl { margin: 0; padding: 0; }
.tipp-option dt { font-weight: bold; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.tipp-option dd { margin: 0; font-size: 0.85rem; text-transform: none; letter-spacing: normal; }

/* Thought options (select_primary, dear_give) */
.thought-options { margin-bottom: 1rem; }
.thought-option {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
  border: 1px solid transparent;
  cursor: pointer;
}
.thought-option:hover { background: rgba(44, 44, 44, 0.04); }
.thought-option input { margin-top: 0.2rem; flex-shrink: 0; }
.thought-text { font-weight: bold; }
.thought-score { font-size: 0.8rem; color: rgba(44, 44, 44, 0.6); }

/* Navigation — now lives in bottom drawer; keep in-content fallback */
.navigation {
  display: none;
}

/* Side-by-side rational response */
.response-grid {
  display: grid;
  grid-template-columns: 1fr 8rem;
  gap: 0;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.response-grid textarea {
  width: 100%;
  min-height: 5rem;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  outline: none;
  resize: vertical;
}
.response-grid input[type="number"] {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.4rem;
  text-align: center;
  outline: none;
}
.response-grid .response-grid__header {
  background: rgba(44, 44, 44, 0.06);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: bold;
}
.response-grid .response-grid__header:last-child {
  border-left: 1px solid var(--border);
  text-align: center;
}

/* Side-by-side evidence (stacks on narrow screens) */
.evidence-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.evidence-grid__header {
  background: rgba(44, 44, 44, 0.06);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: bold;
}
.evidence-grid__header:last-child { border-left: 1px solid var(--border); }
.evidence-grid__cell { display: flex; }
.evidence-grid__cell:last-child { border-left: 1px solid var(--border); }
.evidence-grid textarea {
  width: 100%;
  min-height: 8rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  outline: none;
  resize: vertical;
}

/* Biased thoughts grid (mirrors response-grid structure, multi-row) */
.thoughts-grid {
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.thoughts-grid__header {
  display: grid;
  grid-template-columns: 1fr 8rem;
  background: rgba(44, 44, 44, 0.06);
  border-bottom: 1px solid var(--border);
}
.thoughts-grid__header > div {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.5rem;
  font-weight: bold;
}
.thoughts-grid__header > div:last-child {
  border-left: 1px solid var(--border);
  text-align: center;
}
.thoughts-grid__row {
  display: grid;
  grid-template-columns: 1fr 8rem;
  border-bottom: 1px solid var(--border);
}
.thoughts-grid__row:last-child { border-bottom: none; }
.thoughts-grid__row > div:last-child {
  border-left: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.thoughts-grid textarea {
  width: 100%;
  min-height: 3rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  outline: none;
  resize: vertical;
}
.thoughts-grid input[type="number"] {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem;
  text-align: center;
  outline: none;
}

/* Post-believability grid (Thought | Pre | Post — 3-column variant of thoughts-grid) */
.post-believability-grid {
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}
.post-believability-grid__header {
  display: grid;
  grid-template-columns: 1fr 4rem 6.5rem;
  background: rgba(44, 44, 44, 0.06);
  border-bottom: 1px solid var(--border);
}
.post-believability-grid__header > div {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.5rem;
  font-weight: bold;
}
.post-believability-grid__header > div:not(:first-child) {
  border-left: 1px solid var(--border);
  text-align: center;
}
.post-believability-grid__row {
  display: grid;
  grid-template-columns: 1fr 4rem 6.5rem;
  border-bottom: 1px solid var(--border);
}
.post-believability-grid__row:last-child { border-bottom: none; }
.post-believability-grid__row > div {
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  vertical-align: middle;
}
.post-believability-grid__row > div:not(:first-child) {
  border-left: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.post-believability-grid input[type="number"] {
  width: 100%;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem;
  text-align: center;
  outline: none;
}

/* Workbook drawer nav slot */
#workbook-drawer-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Evaluation animation */
#evaluation-result.evaluation {
  animation: workbook-rise 0.4s ease-out both;
}

/* TIPP revealed suds section */
#suds-rerate {
  animation: workbook-rise 0.35s ease-out both;
}

/* Evaluation feedback */
.evaluating { font-style: italic; color: rgba(44, 44, 44, 0.6); }

.evaluation {
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
  border-left: 3px solid var(--border);
}
.evaluation p { margin: 0 0 0.75rem; }
.evaluation--challenge {
  border-color: var(--peach);
  background: rgba(232, 133, 90, 0.08);
}
.evaluation--affirm {
  border-color: var(--teal);
  background: rgba(74, 155, 142, 0.08);
}

/* Button variants */
.btn--secondary {
  background: transparent;
  color: var(--charcoal);
  border-color: rgba(44, 44, 44, 0.4);
}
.btn--secondary:hover {
  background: rgba(44, 44, 44, 0.06);
  color: var(--charcoal);
}
