/* ==========================================================================
   Sudoku.School — Tutorial CSS (tutorial.css)
   CSS-drawn Sudoku boards, tooltips, and teaching styles
   ========================================================================== */

/* ---------- Tutorial Board Base ---------- */
.tut-board {
    display: grid;
    width: max-content;
    max-width: 100%;
    border: 3px solid var(--nb-border);
    border-radius: 10px;
    background: linear-gradient(180deg, #ffffff 0%, #fffdf7 100%);
    box-shadow: 0 0 0 1px rgba(34, 34, 34, 0.05), var(--nb-shadow-md);
    margin: 24px auto;
    overflow: hidden;
    position: relative;
    isolation: isolate;
}

/* 4x4 mini board */
.tut-board--4x4 {
    grid-template-columns: repeat(4, 48px);
    grid-template-rows: repeat(4, 48px);
}

/* 9x9 full board */
.tut-board--9x9 {
    grid-template-columns: repeat(9, 40px);
    grid-template-rows: repeat(9, 40px);
}

/* Responsive sizing */
@media (max-width: 600px) {
    .tut-board--4x4 {
        grid-template-columns: repeat(4, 40px);
        grid-template-rows: repeat(4, 40px);
    }

    .tut-board--9x9 {
        grid-template-columns: repeat(9, 32px);
        grid-template-rows: repeat(9, 32px);
    }
}

/* ---------- Board Figure Wrapper ---------- */
.tut-figure {
    text-align: center;
    margin: 24px 0;
}

.tut-figure figcaption {
    font-size: 0.9rem;
    color: #666;
    margin-top: 8px;
    font-style: italic;
}

/* ---------- How-To Article Spacing ---------- */
#how-to-play {
    margin-top: 28px;
}

#how-to-play > h2 {
    margin-bottom: 18px;
}

#how-to-play > p {
    margin-bottom: 24px;
}

#how-to-play section {
    margin-top: 32px;
}

#how-to-play h3 {
    margin-bottom: 14px;
}

#how-to-play p,
#how-to-play ul,
#how-to-play ol {
    margin: 0 0 16px;
    line-height: 1.8;
}

#how-to-play section > :last-child {
    margin-bottom: 0;
}

.tut-caption {
    margin: 12px auto 0;
    max-width: 760px;
    text-align: center;
    line-height: 1.7;
    font-size: 0.95rem;
    color: #333;
}

/* ---------- Cell Base ---------- */
.tut-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--nb-border);
    background: #fffef8;
    border: 1px solid rgba(34, 34, 34, 0.22);
    position: relative;
    cursor: default;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.tut-board--9x9 .tut-cell {
    font-size: 1.1rem;
}

@media (max-width: 600px) {
    .tut-cell {
        font-size: 1.05rem;
    }

    .tut-board--9x9 .tut-cell {
        font-size: 0.9rem;
    }
}

/* ---------- Box Borders (thick lines for 3x3 boxes) ---------- */

/* 4x4 board: 2x2 boxes */
.tut-board--4x4 .tut-cell:nth-child(4n+3) {
    border-right: 3px solid var(--nb-border);
}
.tut-board--4x4 .tut-cell:nth-child(n+5):nth-child(-n+8) {
    border-bottom: 3px solid var(--nb-border);
}

/* 9x9 board: thick borders every 3 cells */
/* Right borders for columns 3 and 6 */
.tut-board--9x9 .tut-cell:nth-child(9n+3) {
    border-right: 3px solid var(--nb-border);
}
.tut-board--9x9 .tut-cell:nth-child(9n+6) {
    border-right: 3px solid var(--nb-border);
}

/* Bottom borders for rows 3 and 6 */
.tut-board--9x9 .tut-cell:nth-child(n+19):nth-child(-n+27) {
    border-bottom: 3px solid var(--nb-border);
}
.tut-board--9x9 .tut-cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 3px solid var(--nb-border);
}

/* ---------- Cell Modifiers ---------- */

/* Given / clue digit */
.tut-cell--given {
    background: #f5f5f0;
    font-weight: 800;
}

/* User-entered digit */
.tut-cell--user {
    color: var(--nb-blue);
    font-weight: 700;
}

/* Error digit */
.tut-cell--error {
    color: var(--nb-coral);
    background: #fff0f0;
}

/* Highlighted cell (selected) */
.tut-cell--highlight {
    background: var(--nb-yellow) !important;
    z-index: 1;
}

/* Row highlight */
.tut-cell--row-hl {
    background: #FFF9DB;
}

/* Column highlight */
.tut-cell--col-hl {
    background: #E7F5FF;
}

/* Box highlight */
.tut-cell--box-hl {
    background: #F3F0FF;
}

/* Diagonal cell (on main or anti-diagonal) */
.tut-cell--diag {
    background: #FFF4E6;
}

/* Diagonal highlight (strong, for answer cell on diagonal) */
.tut-cell--diag-hl {
    background: #FFE8CC !important;
    z-index: 1;
}

/* Killer tutorial board */
.tut-board--killer .tut-cell {
    align-items: flex-end;
    justify-content: center;
    padding: 11px 4px 4px;
}

.tut-board--killer .tut-cell::before {
    content: attr(data-sum);
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 0.52rem;
    line-height: 1;
    font-weight: 800;
    color: var(--nb-border);
    background: rgba(255, 255, 255, 0.92);
    padding: 1px 4px;
    border-radius: 999px;
    box-shadow: 0 0 0 1px rgba(34, 34, 34, 0.14);
    opacity: 0;
    pointer-events: none;
}

.tut-board--killer .tut-cell[data-sum]::before {
    opacity: 1;
}

.tut-board--killer .tut-cell--cage-a {
    background: #FFF1F0;
}

.tut-board--killer .tut-cell--cage-b {
    background: #FFF7E6;
}

.tut-board--killer .tut-cell--cage-c {
    background: #EEF7FF;
}

.tut-board--killer .tut-cell--cage-d {
    background: #F3F0FF;
}

.tut-board--killer .tut-cell--cage-top {
    border-top: 3px solid var(--nb-border) !important;
}

.tut-board--killer .tut-cell--cage-right {
    border-right: 3px solid var(--nb-border) !important;
}

.tut-board--killer .tut-cell--cage-bottom {
    border-bottom: 3px solid var(--nb-border) !important;
}

.tut-board--killer .tut-cell--cage-left {
    border-left: 3px solid var(--nb-border) !important;
}

@media (max-width: 600px) {
    .tut-board--killer .tut-cell {
        padding-top: 9px;
    }

    .tut-board--killer .tut-cell::before {
        font-size: 0.42rem;
        left: 2px;
        top: 2px;
        padding: 1px 3px;
    }
}

/* Success / solved cell */
.tut-cell--success {
    background: #D3F9D8;
    color: var(--nb-border);
}

/* Empty cell (placeholder) */
.tut-cell--empty {
    color: transparent;
}

/* ---------- Candidate Notes (pencil marks) ---------- */
.tut-notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    padding: 1px;
}

.tut-note {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 600;
    color: #666;
    line-height: 1;
}

.tut-board--4x4 .tut-note {
    font-size: 0.65rem;
}

@media (max-width: 600px) {
    .tut-note {
        font-size: 0.48rem;
    }
}

/* Eliminated candidate */
.tut-note--elim {
    color: var(--nb-coral);
    text-decoration: line-through;
    opacity: 0.6;
}

/* Confirmed / highlighted candidate */
.tut-note--confirm {
    color: var(--nb-blue);
    font-weight: 800;
    font-size: 0.7rem;
}

.tut-board--9x9 .tut-note--confirm {
    font-size: 0.6rem;
}

/* Empty note slot */
.tut-note--empty {
    visibility: hidden;
}

/* ---------- Tooltip System ---------- */
.tut-tip {
    position: relative;
    cursor: help;
}

.tut-tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--nb-border);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 220px;
    white-space: normal;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 100;
    line-height: 1.3;
    box-shadow: var(--nb-shadow-sm);
}

.tut-tip::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--nb-border);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 101;
}

.tut-tip:hover::after,
.tut-tip:hover::before,
.tut-tip:focus::after,
.tut-tip:focus::before {
    opacity: 1;
}

/* Tooltip below variant */
.tut-tip--below::after {
    bottom: auto;
    top: calc(100% + 8px);
}

.tut-tip--below::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--nb-border);
}

/* ---------- Tutorial Step Callout ---------- */
.tut-step {
    background: #FFF9DB;
    border: var(--nb-border-w) solid var(--nb-border);
    border-radius: var(--nb-radius);
    padding: 16px 20px;
    margin: 16px 0;
    box-shadow: var(--nb-shadow-sm);
}

.tut-step__title {
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tut-step__title .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--nb-blue);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
    border: 2px solid var(--nb-border);
    flex-shrink: 0;
}

.tut-step p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ---------- Key Term Highlight ---------- */
.tut-term {
    display: inline-block;
    background: var(--nb-yellow);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 700;
    border: 1.5px solid var(--nb-border);
}

/* ---------- Technique Badge ---------- */
.tut-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 2px solid var(--nb-border);
    box-shadow: 2px 2px 0 var(--nb-shadow);
}

.tut-badge--beginner { background: var(--nb-mint); }
.tut-badge--intermediate { background: var(--nb-yellow); }
.tut-badge--advanced { background: var(--nb-coral); color: #fff; }

/* ---------- Rule Box ---------- */
.tut-rule {
    background: var(--nb-card);
    border: var(--nb-border-w) solid var(--nb-border);
    border-left: 6px solid var(--nb-blue);
    border-radius: 0 var(--nb-radius) var(--nb-radius) 0;
    padding: 16px 20px;
    margin: 16px 0;
    box-shadow: var(--nb-shadow-sm);
}

.tut-rule strong {
    color: var(--nb-blue);
}

/* ---------- Example Label ---------- */
.tut-example-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--nb-purple);
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: var(--nb-border-w) solid var(--nb-border);
    box-shadow: 2px 2px 0 var(--nb-shadow);
    margin-bottom: 12px;
}

/* ---------- Arrow indicator for teaching ---------- */
.tut-arrow {
    display: inline-block;
    font-size: 1.2rem;
    color: var(--nb-coral);
    font-weight: 800;
    margin: 0 4px;
    vertical-align: middle;
}

/* ---------- FAQ Section ---------- */
.faq-section {
    margin-top: 2em;
}

.faq-item {
    border: var(--nb-border-w) solid var(--nb-border);
    border-radius: var(--nb-radius);
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: var(--nb-shadow-sm);
}

.faq-item summary {
    padding: 12px 16px;
    font-weight: 700;
    cursor: pointer;
    background: var(--nb-card);
    transition: background-color 0.15s ease;
    list-style: none;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::before {
    content: '▸ ';
    color: var(--nb-blue);
    font-weight: 800;
}

.faq-item[open] summary::before {
    content: '▾ ';
}

.faq-item summary:hover {
    background: #FFF9DB;
}

.faq-item .faq-answer {
    padding: 12px 16px;
    border-top: 1px solid #ddd;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ---------- How-To / FAQ Spacing Overrides ---------- */
#how-to-play {
    margin-top: 36px;
    padding-top: 20px;
    padding-bottom: 20px;
}

#how-to-play > h2 {
    margin-top: 0;
    margin-bottom: 22px;
}

#how-to-play > p {
    margin-bottom: 28px;
}

#how-to-play section {
    margin-top: 36px;
}

#how-to-play h3 {
    margin-bottom: 16px;
}

#faq {
    margin-top: 32px;
    padding-top: 20px;
    padding-bottom: 20px;
}

#faq > h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

#faq .faq-list {
    display: grid;
    gap: 16px;
}

#faq .faq-item {
    margin-bottom: 0;
}

#faq .faq-item summary {
    padding: 16px 20px;
    line-height: 1.5;
}

#faq .faq-item > p {
    margin: 0;
    padding: 16px 20px 18px;
    border-top: 1px solid #ddd;
    line-height: 1.8;
    background: #fffdf7;
}