/* ============================================================
   Plans and Elevations - GCSE Maths activity
   ============================================================ */

:root{
  --ink:            #1e2430;
  --ink-soft:       #5a6472;
  --line:           #d5dae2;
  --paper:          #ffffff;
  --bg:             #eef1f6;
  --accent:         #1f5fa8;
  --accent-dark:    #17497f;
  --brick:          #d4483f;
  --brick-soft:     #e8746c;
  --grid-empty:     #f7f8fa;
  --grid-line:      #9aa3b0;
  --right:          #1e8a52;
  --wrong:          #c22e2e;
  --cell:           46px;
  --radius:         10px;
}

*{ box-sizing: border-box; }

html,body{ margin:0; padding:0; }

body{
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

main{
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ---------- header ---------- */
.page-head{
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 16px 14px;
}
.page-head h1{
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}
.strap{
  margin: 4px 0 0;
  color: var(--ink-soft);
}

/* ---------- panels ---------- */
.panel{
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20,30,50,.05);
}

.viewer-panel{ padding: 12px 14px 10px; margin-bottom: 22px; }

.panel-bar{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.view-tools{ display:flex; flex-wrap:wrap; gap:6px; }

/* ---------- 3D canvas area ---------- */
.view3d{
  position: relative;
  width: 100%;
  height: 440px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#ffffff, #f2f5f9);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.view3d.dragging{ cursor: grabbing; }
.view3d canvas{ display:block; }

.webgl-error{
  position:absolute; inset:0;
  display:flex; flex-direction:column; justify-content:center;
  padding: 24px 32px;
  background: #fff6f6;
  color: #7a2020;
  font-size: .95rem;
}
.webgl-error[hidden]{ display: none; }
.webgl-error code{
  background: #f3dede;
  padding: 1px 5px;
  border-radius: 4px;
}

.hint{
  margin: 8px 2px 2px;
  font-size: .85rem;
  color: var(--ink-soft);
}

/* ---------- the three answer grids ---------- */
.grids{
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: flex-start;
}

.grid-panel{
  flex: 1 1 300px;
  padding: 14px 16px 12px;
}

.grid-panel h2{
  margin: 0 0 10px;
  font-size: 1.06rem;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
}

.grid-wrap{ display:flex; gap:8px; align-items:center; }

.axis-left{
  font-size: .68rem;
  color: var(--ink-soft);
  line-height: 1.25;
  text-align: right;
  width: 40px;
  flex: 0 0 40px;
}

.grid{
  display: grid;
  grid-template-columns: repeat(6, var(--cell));
  grid-template-rows: repeat(6, var(--cell));
  border: 2px solid var(--grid-line);
  background: var(--grid-line);
  gap: 1px;
  width: max-content;
  user-select: none;
}

.cell{
  background: var(--grid-empty);
  cursor: pointer;
  transition: background-color .09s ease;
}
.cell:hover{ background: #e3e9f2; }
.cell.on{ background: var(--brick); }
.cell.on:hover{ background: var(--brick-soft); }
.cell:focus-visible{ outline: 2px solid var(--accent); outline-offset: -2px; }

.grid-note{
  margin: 10px 0 0;
  font-size: .78rem;
  color: var(--ink-soft);
}

/* ---------- tick / cross ---------- */
.mark{
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}
.mark.right{ color: var(--right); }
.mark.wrong{ color: var(--wrong); }

/* ---------- buttons ---------- */
.btn{
  font: inherit;
  font-size: .9rem;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 7px 14px;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}
.btn:active{ transform: translateY(1px); }

.btn-primary{
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 10px 22px;
  font-size: 1rem;
}
.btn-primary:hover{ background: var(--accent-dark); }

.btn-secondary{
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  padding: 10px 18px;
  font-size: 1rem;
}
.btn-secondary:hover{ background: #f2f5f9; }

.btn-ghost{
  background: #f4f6fa;
  color: var(--ink);
  border-color: var(--line);
}
.btn-ghost:hover{ background: #e6ebf3; }

/* ---------- action row ---------- */
.actions{
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}

.feedback{
  margin: 0;
  font-weight: 600;
  flex: 1 0 100%;
  text-align: center;
}
.feedback.right{ color: var(--right); }
.feedback.wrong{ color: var(--wrong); }

.page-foot{
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px 30px;
  color: var(--ink-soft);
  font-size: .84rem;
}

/* ---------- smaller screens ---------- */
@media (max-width: 780px){
  :root{ --cell: 40px; }
  .view3d{ height: 340px; }
  .grid-panel{ flex: 1 1 100%; }
}

@media (max-width: 400px){
  :root{ --cell: 34px; }
}

@media print{
  .view-tools, .actions, .hint { display:none; }
}
