/* Smooth scrolling for the #learn anchor link */
html {
    scroll-behavior: smooth;
}

/* SubnetIPv4 uses a flatter page shell than the shared white "card" — its
   background matches the page instead of standing out as its own card,
   same as the TCP tools.

   No top padding, same reasoning as the TCP tools below: this wrapper has
   no visible card boundary of its own, so top padding here would just be
   dead space stacked on top of .main-content-placeholder's margin. Side and
   bottom padding come from the shared --tool-padding-* tokens in
   base/layout.css so this tool's edge inset always matches the other three. */
.content-placeholder {
    background: var(--surface-page);
    box-shadow: none;
    padding: 0 var(--tool-padding-x) var(--tool-padding-bottom);
}

/* The vertical gap between the form and learning-series cards.
   #mainContainer is SubnetIPv4's own top-level wrapper div, so this rule is
   load-bearing even though the class name gives no hint of that. */
#mainContainer {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.learn-anchor-div {
    position: relative;
    top: -75px;
}

/* Video loading placeholders */
.video-placeholder {
    width: 400px;
    height: 260px;
    background: var(--surface-sunken);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.video-loading {
    text-align: center;
    color: var(--text-muted);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 8px solid var(--border);
    border-top: 8px solid var(--accent-title);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.video-error-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex-direction: column;
    color: var(--text-muted);
}

.video-error-link {
    color: var(--accent-title);
    text-decoration: none;
    margin-top: 10px;
}

/* ── Form/table styles ──
   Tokens scoped to this tool's wrapper rather than :root so they can't
   collide with another tool's or leak into the shared chrome. */
#mainContainer {
    --answerbox-bg: var(--data-answer-bg);
    --next-btnbg: var(--data-next);
    --next-hover-btnbg: var(--data-next-hover);
    --show-btnbg: var(--data-show);
    --show-hover-btnbg: var(--data-show-hover);
    --check-btnbg: var(--data-check);
    --check-hover-btnbg: var(--data-check-hover);
    --ip-pill-width: 25ch;
    --table-border: var(--data-table-border);
}

#mainContainer input {
    font-family: var(--font-mono);
}

.color-next {
    color: var(--next-btnbg);
}

.color-show {
    color: var(--show-btnbg);
}

.color-check {
    color: var(--check-btnbg);
}

.text-sm {
    font-size: 16px;
}

/* Auto-filled read-only field styling */
.ip-octet.auto-filled-readonly {
    background-color: var(--answerbox-bg);
    color: var(--text-muted);
    cursor: not-allowed !important;
}

.check-ok-icon {
    display: none;
}

.ok-icon {
    display: inline-flex;
    width: 20px;
    height: 20px;
    align-items: center;
    justify-content: center;
    border-radius: 40px;
}

/* Ensure SVG icons are perfectly centered */
.ok-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.mc-item {
    padding: 20px;
    border-radius: var(--card-radius);
    background-color: var(--surface-card);
    box-shadow: var(--shadow-card);
}

.subnetipv4-content {}

.learning-container {}

.learning-container p {
    margin: 10px auto;
    max-width: 620px;
}

.info-text-container {
    background-color: var(--data-hint-bg);
    border-radius: 8px;
    padding: 12px 20px 12px 30px;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
}

.info-text-container li {
    text-align: start;
    margin-bottom: 0.3em;
}

.info-text-container ul>li>ul {
    padding-left: 1em;
}

.info-text-container a,
.info-text-container a:visited {
    color: var(--next-btnbg);
    text-decoration: none;
}

.info-text-container a:hover {
    text-decoration: underline;
}

.soft-emphasis {
    font-weight: 500;
}

.learn-title-subnetting {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 16px;
}

.user-input-target:focus-visible {
    outline: none;
}

.auto-check-button-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.sm-table {
    display: flex;
    max-width: 880px;
    width: 100%;
    margin: 0 auto;
    margin-top: 40px;
    gap: 40px;
    align-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 20px;
}

.sm-table .sm-cell-vid iframe {
    border-radius: 8px;
}

.sm-cell-text {
    text-align: start;
    font-size: 16px;
}

.subnetipv4-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 880px;
    width: 100%;
    margin: 24px auto;
}

.new-problem-button {
    background-color: var(--next-btnbg);
    color: var(--text-on-accent);
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    height: 31px;
}

.new-problem-button:hover {
    background-color: var(--next-hover-btnbg);
}

.new-problem-button:active {
    background-color: var(--next-btnbg);
}

.new-problem-button:focus {
    outline: none;
}

.main-table-container {
    width: 100%;
    border: 1px solid var(--table-border);
    border-radius: 6px;
    overflow: hidden;
}

.main-table-row {
    display: flex;
    justify-content: space-around;
    width: 100%;
    border-bottom: 1px solid var(--border-strong);
    min-height: 45px;
    align-items: center;
    background: var(--surface-card);
    /* Fallback for the gradient below */
    background: linear-gradient(to right, var(--surface-card) 0%, var(--surface-card) 70%, var(--answerbox-bg) 71%, var(--answerbox-bg) 100%);
}

.main-table-labels {
    width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    flex: 2 2 auto;
    min-height: 1em;
}

.main-table-ip-addresses {
    width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    height: 100%;
    min-width: max-content;
    flex: 3 0 auto;
}

.ip-input {}

.ip-answer {
    border: 1px solid var(--border-strong);
}

.ip-answer input:focus-visible {
    outline: none;
}

.ip-input input:focus-visible {
    outline: none;
}

.sub-table-row {
    width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    background-color: var(--answerbox-bg);
    height: 100%;
    min-width: max-content;
    flex: 3 0 auto;
}

.main-table-answers {
    width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    background-color: var(--answerbox-bg);
    height: 100%;
    min-width: max-content;
    flex: 3 0 auto;
}

.main-table-answers p,
.main-table-ip-addresses p {
    width: 100%;
    font-weight: 500;
}

.main-table-show {
    width: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    height: 100%;
    background-color: var(--answerbox-bg);
    flex: 1 5 auto;
}

.main-table-show p {
    font-weight: 500;
}

.main-table-correct {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    width: 120px;
    height: 100%;
    flex: 1 5 auto;
    min-width: 1ch;
}

.main-table-correct p {
    font-weight: 500;
}

.problem-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 16px;
    background: var(--data-panel-bg);
    border: 1px solid var(--data-panel-border);
    padding: 10px 10px;
    width: auto;
    border-radius: 4px;
}

.pbox-item {
    align-self: stretch;
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 0 1 auto;
}

.pbox-label {}

.pbox-label-text {
    font-weight: 600;
}

.pbox-next {}

.pbox-targetip {
    gap: 10px;
}

.pbox-targetip input {
    text-align: center;
}

.pbox-targetip .ip-dot {
    font-weight: 700;
}

.ip-pill {
    border: 1px solid var(--text-primary);
    border-radius: 8px;
}

.sub-table-answer .ip-dot,
.main-table-answer .ip-dot,
.sub-table-answer .ip-pill,
.main-table-answers .ip-pill {
    border-color: var(--text-muted);
    color: var(--text-muted);
}

.ip-octet {
    background: inherit;
    border: none;
    border-radius: 8px;
    padding: 5px 0px;
    width: 4ch;
    text-align: center;
    font-size: inherit;
    font-weight: 500;
}

.ip-octet.ip-cidr {
    width: 3ch;
    margin-right: 5px;
}

.ip-slash {
    margin-left: 5px;
}

.problem-box .ip-target-cidr .ip-octet,
.problem-box .ip-target .ip-octet {
    font-weight: 800;
    padding: 2px;
}

.view-check-button {
    background: var(--data-panel-bg);
    border: 1px solid var(--data-panel-border);
    color: var(--show-btnbg);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    position: relative;
    top: 1px;
}

.view-check-button:hover {
    border: 1px solid var(--show-hover-btnbg);
    color: var(--show-hover-btnbg);
}

.check-button {
    border: 1px solid var(--data-check);
    border-radius: 8px;
    background-color: var(--data-check);
    padding: 6px 10px;
    cursor: pointer;
    position: relative;
    top: 1px;
}

.show-all-container {
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    gap: 16px;
    align-items: center;
    justify-content: center;
    width: 100%;
}


.show-all-button {
    background-color: var(--show-btnbg);
    color: var(--text-on-accent);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    padding: 5px 10px;
    margin-right: 10px;
    cursor: pointer;
}

.show-all-button:hover {
    background-color: var(--show-hover-btnbg);
}

.show-all-button:active {
    background-color: var(--show-btnbg);
}

.show-all-button:focus {
    outline: none;
}

.check-all-button {
    background-color: var(--check-btnbg);
    color: var(--text-on-accent);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
}

.check-all-button:hover {
    background-color: var(--check-hover-btnbg);
}

.check-all-button:active {
    background-color: var(--check-btnbg);
}

.check-all-button:focus {
    outline: none;
}

.sub-table-label {
    display: none;
}


.sm-cell-text-title {
    font-size: 18px;
    margin-bottom: 24px;
}

.sm-cell-text-link {
    margin-top: 16px;
    color: var(--accent-title);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--accent-title);
}

.sub-table {
    display: none;
}

.auto-check-button {
    margin-left: 10px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    background: var(--data-panel-bg);
    border: 1px solid var(--data-panel-border);
}

.auto-check-button input[type="checkbox"] {
    accent-color: var(--data-panel-border);
    transform: scale(1.2);
    position: relative;
    top: -0.5px;
}

.auto-check-button input[type="checkbox"]:checked {
    border: 1px solid var(--text-primary);
    border-radius: 8px;
}

.buttons-options-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.sub-table-show {
    display: none;
    width: 100px;
}


.main-table-header-row-header {
    font-weight: 600;
    height: 48px;
}

.hidden-submit {
    border: 0;
    padding: 0;
    font-size: 0;
}

.auto-check-button-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

@media (max-width: 768px) {
    .video-placeholder {
        width: 100%;
    }

    .ip-octet {
        width: 3.5ch;
    }

    .address-text {
        display: none;
    }

    .hide-answer-mobile-view {
        display: none !important;
    }

    .sub-table {
        display: block;
    }

    .ip-input {
        display: flex;
    }

    .ip-answer {
        display: flex;
    }

    .sub-table-answer {
        width: 200px;
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .pbox-label-text {
        margin-right: 0px;
        font-size: 18px;
    }

    .main-table-container {
        box-shadow: none;
        border: none;
        border-radius: 0px;
    }

    .main-table-row {
        height: auto;
        border-bottom: none;
        background: inherit;
    }

    .main-table-correct {
        justify-content: center;
    }


    .subnetipv4-content {
        padding: 0px;
    }

    .learning-container {
        padding: 16px;
    }

    .learning-container .sm-table {
        flex-direction: column;
    }

    .sm-table .sm-cell-vid iframe {
        width: 100% !important;
    }

    .sm-cell-text {
        order: 1;
    }

    .ok-icon {
        width: 6ch;
    }

    .sub-table-row .sub-table-label {
        width: 100px !important;
        text-align: center;
        font-weight: 500;
    }

    .show-all-container {
        margin-top: 16px;
    }

    .main-table-answers {
        width: 100%;
        height: 45px;
        justify-content: space-around;
    }

    .sub-table-row {
        width: 100%;
        height: 45px;
        justify-content: space-around;
    }

    .sub-table-show {
        display: block;
    }

    /* Row wrappers — remove space distribution differences and normalize */
    .main-table-row {
        display: flex;
        align-items: center;
        justify-content: normal;
        gap: 12px;
        width: 100%;
        padding-inline: 0;
        box-sizing: border-box;
    }

    .sub-table>.sub-table-row {
        display: flex;
        align-items: center;
        justify-content: normal;
        gap: 12px;
        width: 100%;
        padding-inline: 0;
        box-sizing: border-box;
    }

    /* Left column (labels) — equal left gutter */
    .main-table-row>.main-table-labels,
    .sub-table-row>.sub-table-label {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        justify-content: flex-end;
        text-align: right;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0;
        padding: 0;
        width: auto;
    }

    /* Center column (IP / Answer) — constant track width */
    .main-table-row>.main-table-ip-addresses,
    .sub-table-row>.sub-table-answer {
        flex: 0 0 var(--ip-pill-width);
        min-width: 17ch;
        max-width: var(--ip-pill-width);
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .main-table-row>.main-table-ip-addresses>*,
    .sub-table-row>.sub-table-answer>* {
        margin: 0;
        max-width: 100%;
    }

    /* Right column (Correct? / Show) — equal right gutter */
    .main-table-row>.main-table-correct,
    .sub-table-row>.sub-table-show {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        white-space: nowrap;
        margin: 0;
        padding: 0;
        width: auto;
    }
}

@media (max-width: 576px) {
    .problem-box {
        width: 55%;
        min-width: 295px;
        margin-bottom: 8px;
    }

    .pbox-label {
        order: 1;
        flex: 0 1 auto;
    }

    .pbox-targetip {
        order: 3;
        flex: 0 0 100%;
    }

    .pbox-next {
        order: 2;
        flex: 0 1 auto;
    }

    .subnetipv4-form {
        padding: 10px 0px;
    }

    .sub-table-row .sub-table-label {
        width: 100px !important;
        text-align: center;
    }

    .sub-table-label {
        width: 100%;
        font-weight: 500;
    }

    .main-table-show {
        width: 120px;
    }

    .main-table-correct {
        width: 100px;
    }

    .show-all-container {
        flex-wrap: wrap;
    }

    .ip-answer {
        margin-left: 10px;
    }

    .main-table-answers {
        width: 100%;
        background-color: var(--answerbox-bg);
        padding: 5px 10px;
    }




    .sub-table-row,
    .main-table-answers {
        border-bottom: none !important;
    }

    .content-placeholder {
        padding: 1rem 0;
    }

    .pbox-label-text {
        font-size: 16px;
    }


    .main-table-row,
    .sub-table>.sub-table-row {
        gap: 1px;
    }

    .main-table-row>.main-table-ip-addresses,
    .sub-table-row>.sub-table-answer {
        flex: 0 0 17ch;
        min-width: 17ch;
        max-width: 17ch;
    }
}
