/*
 * Coding Ireland proprietary interactive activity
 * Copyright (c) 2017-2026 Coding Ireland. All rights reserved.
 *
 * Part of the Coding Ireland online learning platform. Licensed for use only
 * as delivered on the platform. Copying, redistributing, or adapting this
 * file, in whole or in part, for use in any other product or service is not
 * permitted. Ref: CI-maths-pattern-blocks
 */
/*
 * pattern-blocks — coloured geometric shapes (triangle / square /
 * circle / hexagon / diamond / star / rhombus / trapezoid) placed
 * onto a canvas. Two layouts: `sequence` (continue-the-pattern
 * horizontal strip) and `grid` (fill cells, used for tessellation
 * and sort-by-property). Both share the same shape palette and
 * the standard explore / challenge / display modes.
 */

/* Honor the [hidden] HTML attribute even on elements whose later rules
 * set an explicit display: value (mode chip, target panel, callout). */
.maths-activity [hidden] { display: none !important; }

.maths-activity .pb-stage {
    background: #fffaf0;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(20, 40, 80, 0.05);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.maths-activity .pb-canvas {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* ----- Sequence layout ----- */

.maths-activity .pb-sequence {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.maths-activity .pb-slot {
    width: 64px;
    height: 64px;
    background: #fff;
    border: 2px dashed #b0bec5;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 120ms ease-out, border-color 120ms ease-out;
}

.maths-activity .pb-slot.pb-filled {
    border-style: solid;
    border-color: #455a64;
    background: #fff;
}

.maths-activity .pb-slot.pb-empty:hover { background: #fff8e1; border-color: #f0c14b; }
.maths-activity .pb-slot.pb-target-correct { border-color: #2E7D32; background: #e8f5e9; }
.maths-activity .pb-slot.pb-target-incorrect { border-color: #c62828; background: #ffebee; }

.maths-activity .pb-slot-q {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 28px;
    color: #6b7280;
}

/* ----- Grid layout ----- */

.maths-activity .pb-grid {
    display: grid;
    gap: 4px;
    background: #455a64;
    padding: 4px;
    border-radius: 10px;
}

.maths-activity .pb-cell {
    width: 56px;
    height: 56px;
    background: #fff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: background-color 120ms ease-out;
}

/* Tessellation view: the copies must MEET. The default grid puts every shape in
   its own bordered cell with a gap around it, which on a tessellation lesson
   shows the opposite of the point — three QA findings said so in three different
   words. Here the cells are flush and the shape is drawn to the full cell, so a
   square tiling looks solid and a circle tiling visibly leaves corner gaps. */
.maths-activity .pb-grid--tile {
    gap: 0;
    padding: 0;
    background: transparent;
}

.maths-activity .pb-grid--tile .pb-cell {
    border-radius: 0;
    background: transparent;
    /* The cell is a <button>: its default padding and border shrank a 56px tile
       to 40px and reintroduced the very gap this view exists to remove. */
    padding: 0;
    border: 0;
}

/* An empty cell in the flush square/triangle view. The outline is drawn INSIDE
   the box with an inset shadow rather than a border, because a border would
   shrink the tile and reintroduce the very gap this view exists to remove — the
   same trap the padding/border reset above already had to undo. A cell with a
   shape in it carries no guide, so placed tiles still meet edge to edge. */
.maths-activity .pb-grid--tile .pb-cell.pb-tile-empty {
    box-shadow: inset 0 0 0 1px #C3CBD8;
}
.maths-activity .pb-grid--tile .pb-cell.pb-tile-empty:hover {
    box-shadow: inset 0 0 0 1.5px #849AB5;
    background: #EEF2F7;
}

.maths-activity .pb-grid--tile .pb-cell.pb-prefilled { background: transparent; }
.maths-activity .pb-grid--tile .pb-cell:hover { background: rgba(255, 248, 225, 0.5); }
.maths-activity .pb-grid--tile .pb-cell svg { display: block; }

.maths-activity .pb-cell:hover { background: #fff8e1; }
.maths-activity .pb-cell.pb-prefilled { background: #f5f5f5; cursor: default; }
.maths-activity .pb-cell.pb-target-correct { background: #e8f5e9; }
.maths-activity .pb-cell.pb-target-incorrect { background: #ffebee; }

/* Honeycomb (tessellate: true) — hexagons in offset rows, edge-to-edge */
.maths-activity .pb-honeycomb { position: relative; padding: 8px; }
.maths-activity .pb-hex { position: absolute; line-height: 0; }
.maths-activity .pb-hex svg { display: block; }

/* An empty position in the tessellation view. Drawn as a faint hex outline so the
   class can see where the next tile goes and place it edge to edge — the square
   grid could only ever show copies sitting apart in their own cells. */
.maths-activity .pb-hex-empty {
    background: no-repeat center / 100% 100%
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='4 3 42 44'%3E%3Cpolygon points='25,3 46,14 46,36 25,47 4,36 4,14' fill='none' stroke='%23C3CBD8' stroke-width='1.5' stroke-dasharray='4 3'/%3E%3C/svg%3E");
    cursor: pointer;
}

.maths-activity .pb-hex-empty:hover {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='4 3 42 44'%3E%3Cpolygon points='25,3 46,14 46,36 25,47 4,36 4,14' fill='%23EEF2F7' stroke='%23849AB5' stroke-width='1.5'/%3E%3C/svg%3E");
}

/* Triangle lattice (tessellate: true, triangles only): neighbours point opposite
   ways and share an edge, so two make a diamond and six a hexagon. */
.maths-activity .pb-trilattice { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.maths-activity .pb-tri { cursor: pointer; }
.maths-activity .pb-tri-empty:hover { fill: #eef2f7; stroke: #849ab5; stroke-dasharray: none; }
body.display-mode .maths-activity .pb-tri,
.maths-activity .pb-tri.pb-prefilled { cursor: default; }

/* ----- Palette ----- */

.maths-activity .pb-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 12px;
    padding: 0.625rem 0.875rem;
    box-shadow: 0 2px 8px rgba(20, 40, 80, 0.04);
}

.maths-activity .pb-palette-btn {
    width: 56px;
    height: 56px;
    background: #fff;
    border: 2px solid #cfd8dc;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
}

.maths-activity .pb-palette-btn:hover { border-color: #6b7280; }

.maths-activity .pb-palette-btn.pb-active {
    border-color: var(--maths-primary, #2E7D32);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.25);
}

.maths-activity .pb-palette-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--maths-text-muted, #6b7280);
    align-self: center;
    margin-right: 0.4rem;
}

/* ----- Mode + chrome ----- */

.maths-activity .pb-mode-chip {
    display: inline-block;
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    margin-top: 0.25rem;
}

.maths-activity .pb-target-label {
    font-weight: 800;
    color: #8d4e0b;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.maths-activity .pb-target-prompt { flex: 1; font-weight: 700; color: #1f2937; }

.maths-activity .pb-your-turn {
    margin-top: 1.25rem;
    background: #f1f8e9;
    border: 1px solid #aed581;
    border-radius: 14px;
    padding: 1rem 1.25rem;
}

.maths-activity .pb-your-turn-label {
    font-weight: 800;
    color: #33691e;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.maths-activity .pb-your-turn-list { margin: 0; padding-left: 1.25rem; color: #1f2937; font-weight: 600; }
.maths-activity .pb-your-turn-list li { margin-bottom: 0.25rem; }

/* Display mode — read-only pattern. Hide the palette (no shape picking),
 * target panel, callout and challenge runner; lock slots and cells.
 * Tighten stage padding. Your-turn prompts stay — those are
 * display-only discussion prompts.
 */
body.display-mode .pb-target-panel,
body.display-mode .pb-callout,
body.display-mode .pb-palette,
body.display-mode #challengeRunner { display: none !important; }

body.display-mode .pb-slot,
body.display-mode .pb-cell { cursor: default !important; pointer-events: none; }

body.display-mode .pb-stage {
    padding: 0.75rem;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

/* The pinned array's name, shown only in display mode (QA #257). The config
 * `title` ("2 rows of 6") had no on-screen home before this, so a display
 * array sat unlabelled and a tester could not tell what it showed. */
.maths-activity .pb-display-caption {
    font-family: "Nunito", sans-serif;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--maths-primary-dark, #1b5e20);
    background: #f1f8e9;
    border: 1px solid #aed581;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    text-align: center;
    margin-bottom: 0.25rem;
}
