/* ══════════════════════════════════════════
   INSTRUCTOR QUICK TOOLS: coin, die, card and random integer.
   On Activities they slide out from a tab on the right edge; on For Instructors (.tools-inline) they sit in the page
   ══════════════════════════════════════════ */

/* Toggle tab on right edge */
.tools-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    background: #2A6F87;
    color: #fff;
    border: none;
    border-radius: 10px 0 0 10px;
    padding: 14px 10px;
    cursor: pointer;
    font-size: 1.3rem;
    line-height: 1;
    box-shadow: -2px 0 12px rgba(26,35,50,0.12);
    transition: background 0.2s, right 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    writing-mode: vertical-lr;
}
.tools-tab:hover { background: #1e5266; }
.tools-tab .tab-label {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.tools-tab .tab-icon {
    font-size: 1.2rem;
    writing-mode: horizontal-tb;
}
.tools-tab.shifted { right: 300px; }

/* Slide-out panel */
.tools-panel {
    position: fixed;
    right: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: #fff;
    border-left: 1px solid #d1d9e0;
    box-shadow: -4px 0 24px rgba(26,35,50,0.1);
    z-index: 999;
    transition: right 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.tools-panel.open { right: 0; }

.tools-panel .panel-header {
    padding: 20px 20px 14px;
    border-bottom: 1px solid #d1d9e0;
    background: linear-gradient(145deg, #f7f9fb 0%, #eef2f5 100%);
}
.tools-panel .panel-header h2 {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #1a2332;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

/* Tool card */
.tool-card {
    padding: 18px 20px;
    border-bottom: 1px solid #d1d9e0;
    border-left: 4px solid transparent;
}
.tool-card:last-child { border-bottom: none; }
.tool-card.tool-coin { border-left-color: #2A6F87; }
.tool-card.tool-die { border-left-color: #2E8B57; }
.tool-card.tool-card-draw { border-left-color: #9B0B0B; }
.tool-card.tool-rand { border-left-color: #b8860b; }

.tool-label {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #56657a;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Result display */
.tool-result {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: #f7f9fb;
    border: 1px solid #d1d9e0;
    position: relative;
    overflow: hidden;
}

/* Coin */
.tools-panel .coin {
    width: 64px; height: 64px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Source Sans 3', sans-serif;
    font-weight: 700; font-size: 1.1rem;
    color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    user-select: none;
}
.tools-panel .coin.heads {
    background: linear-gradient(145deg, #3a8ba6, #1e5266);
    box-shadow: 0 2px 8px rgba(42,111,135,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}
.tools-panel .coin.tails {
    background: linear-gradient(145deg, #d4a017, #966d09);
    box-shadow: 0 2px 8px rgba(184,134,11,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}
.tools-panel .coin.small { width: 52px; height: 52px; font-size: 0.9rem; }
.tools-panel .coin.spinning { animation: toolsCoinSpin 0.5s ease-out; }
@keyframes toolsCoinSpin {
    0%   { transform: rotateX(0deg) scale(0.8); }
    25%  { transform: rotateX(180deg) scale(1.05); }
    50%  { transform: rotateX(360deg) scale(0.95); }
    75%  { transform: rotateX(540deg) scale(1.02); }
    100% { transform: rotateX(720deg) scale(1); }
}

/* Die */
.tools-panel .die {
    width: 60px; height: 60px;
    border-radius: 10px;
    background: #fff;
    border: 2px solid #b8c4cf;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Fira Code', monospace;
    font-size: 1.8rem; font-weight: 500; color: #1a2332;
    box-shadow: 0 3px 6px rgba(26,35,50,0.1), inset 0 1px 0 rgba(255,255,255,0.8);
    user-select: none;
}
.tools-panel .die.rolling { animation: toolsDieRoll 0.4s ease-out; }
@keyframes toolsDieRoll {
    0%   { transform: rotate(0deg) scale(0.8); }
    20%  { transform: rotate(72deg) scale(1.1); }
    40%  { transform: rotate(144deg) scale(0.95); }
    60%  { transform: rotate(216deg) scale(1.05); }
    80%  { transform: rotate(288deg) scale(0.98); }
    100% { transform: rotate(360deg) scale(1); }
}

/* Playing card */
.tools-panel .playing-card {
    width: 56px; height: 80px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #b8c4cf;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    font-family: 'Source Sans 3', sans-serif;
    box-shadow: 0 2px 6px rgba(26,35,50,0.12);
    user-select: none; line-height: 1;
}
.tools-panel .playing-card.drawing { animation: toolsCardDraw 0.4s ease-out; }
@keyframes toolsCardDraw {
    0%   { transform: translateY(20px) rotateY(90deg); opacity: 0; }
    50%  { transform: translateY(-5px) rotateY(0deg); opacity: 1; }
    100% { transform: translateY(0) rotateY(0deg); opacity: 1; }
}
.tools-panel .act-rank { font-size: 1.3rem; font-weight: 700; }
.tools-panel .act-suit { font-size: 1.4rem; line-height: 1; margin-top: -2px; }
.tools-panel .act-name { font-size: 0.75rem; color: #56657a; margin-top: 6px; font-weight: 600; }
.tools-panel .act-display {
    display: flex;
    align-items: center;
    justify-content: center;
}
.tools-panel .suit-red { color: #9B0B0B; }
.tools-panel .suit-black { color: #1a2332; }

/* Random integer */
.tools-panel .random-int-display {
    font-family: 'Fira Code', monospace;
    font-size: 2rem; font-weight: 500; color: #2A6F87;
    user-select: all;
}
.tools-panel .random-int-display.generating { animation: toolsIntFlicker 0.3s ease-out; }
@keyframes toolsIntFlicker {
    0%   { opacity: 0.3; transform: scale(0.9); }
    50%  { opacity: 0.7; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* Buttons */
.tool-btn {
    width: 100%;
    padding: 8px 14px;
    background: #2A6F87;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.tool-btn:hover { background: #1e5266; }
.tool-btn:active { transform: scale(0.98); }

.tool-btn-row { display: flex; gap: 8px; }
.tool-btn-row .tool-btn { flex: 1; }

.tools-panel .reset-btn {
    padding: 8px 12px;
    background: #fff;
    color: #56657a;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    white-space: nowrap;
}
.tools-panel .reset-btn:hover { border-color: #3a8ba6; color: #2A6F87; }

/* Options row */
.tool-options {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.tool-options label {
    font-size: 0.8rem; font-weight: 600; color: #56657a; white-space: nowrap;
}
.tool-options select,
.tool-options input[type="number"] {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.8rem;
    padding: 4px 8px;
    border: 1px solid #d1d9e0;
    border-radius: 6px;
    background: #fff;
    color: #3d4a5c;
    width: 60px;
}
.tool-options input[type="number"] { width: 70px; }

/* History chips */
.tool-history {
    display: flex; gap: 4px;
    margin-top: 8px; flex-wrap: wrap;
}
.history-chip {
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    padding: 2px 7px;
    background: #eef2f5;
    border-radius: 20px;
    color: #56657a;
}

/* Placeholder */
.tool-placeholder {
    color: #56657a;
    font-size: 0.85rem;
    font-style: italic;
    font-family: 'Source Serif 4', Georgia, serif;
}

/* Footer */
.tools-panel .panel-footer {
    margin-top: auto;
    padding: 12px 20px;
    border-top: 1px solid #d1d9e0;
    background: #f7f9fb;
    text-align: center;
    font-size: 0.7rem;
    color: #56657a;
}

/* Hide on mobile — too narrow for a 300px panel */
@media (max-width: 600px) {
    .tools-tab { display: none; }
    .tools-panel { display: none; }
}

/* Print: hide toolbar */
@media print {
    .tools-tab, .tools-panel { display: none !important; }
}

/* ══════════════════════════════════════════
   In the page (For Instructors): four across, two on a tablet, one on a phone
   ══════════════════════════════════════════ */
.tools-panel.tools-inline {
    position: static; right: auto; width: auto; height: auto; z-index: auto; transition: none; overflow: visible;
    display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid #d1d9e0; border-radius: 10px; box-shadow: none;
}
/* each card spans five shared rows (title, settings, result, buttons, history), so the four cards line up row by row:
   the result boxes are one height and Flip, Roll, Draw and Generate sit on one line, even though Card Draw has no settings */
.tools-inline .tool-card { border-bottom: 0; border-right: 1px solid #d1d9e0; min-width: 0;
    display: grid; grid-row: span 5; grid-template-rows: subgrid; align-content: start; }
.tools-inline .tool-label { grid-row: 1; }
.tools-inline .tool-options { grid-row: 2; }
.tools-inline .tool-result { grid-row: 3; min-height: 128px; }
.tools-inline .tool-btn-row { grid-row: 4; }
.tools-inline .tool-history { grid-row: 5; }
/* the columns are narrower than the slide-out panel: smaller dice, and the sum wraps under them when three are rolled */
.tools-inline .die { width: 44px; height: 44px; font-size: 1.35rem; border-radius: 8px; }
.tools-inline #dieResult > div { flex-wrap: wrap; justify-content: center; row-gap: 6px; }
.tools-inline .tool-card:last-child { border-right: 0; }
.tools-inline .tool-options input[type="number"] { flex: 1 1 0; width: 0; min-width: 3.5rem; }
@media (max-width: 960px) {
    .tools-panel.tools-inline { grid-template-columns: 1fr 1fr; }
    .tools-inline .tool-card { border-bottom: 1px solid #d1d9e0; }
}
@media (max-width: 600px) {
    .tools-panel.tools-inline { display: grid; grid-template-columns: 1fr; }
    .tools-inline .tool-card { border-right: 0; }
}
