/* =========================================================
   RESPONSIVE REFINEMENT
   Sister's Baking Studio
   Breakpoints: tablet / smartphone / compact smartphone
   This file intentionally overrides older responsive rules
   without changing the existing brand direction.
========================================================= */

:root {
    --responsive-gutter: clamp(12px, 3.2vw, 24px);
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

body {
    width: 100%;
    min-width: 320px;
    max-width: 100%;
    overflow-x: clip;
}

main,
section,
article,
header,
footer,
.container,
.admin-main,
.panel,
.form-card,
.cart-card {
    min-width: 0;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

input,
select,
textarea,
button {
    max-width: 100%;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

.container {
    width: min(1240px, calc(100% - 44px));
}

.flash {
    width: min(1240px, calc(100% - 44px));
    overflow-wrap: anywhere;
}

/* Medium desktop / tablet landscape */
@media (min-width: 760px) and (max-width: 1100px) {
    .hero {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: center;
        gap: clamp(18px, 3vw, 34px);
        min-height: 0;
        padding: clamp(42px, 5.5vw, 66px) 0 clamp(34px, 4vw, 52px);
    }

    .hero h1 {
        font-size: clamp(3.1rem, 6vw, 4.9rem);
    }

    .hero-copy > p {
        max-width: 100%;
        font-size: clamp(.92rem, 1.35vw, 1.05rem);
    }

    .hero-art {
        width: 100%;
        min-height: clamp(360px, 43vw, 470px);
        max-width: none;
        margin: 0;
    }

    .hero-card {
        width: min(310px, 78%);
        padding: 9px;
        border-radius: 24px;
    }

    .hero-card img {
        height: clamp(255px, 31vw, 340px);
        border-radius: 17px;
    }

    .hero-card-front {
        left: 0;
        top: 28px;
    }

    .hero-card-back {
        right: 0;
        top: 88px;
    }

    .stamp {
        width: 88px;
        height: 88px;
        right: 0;
        top: 0;
        font-size: .78rem;
    }

    .signature-grid {
        gap: 14px;
    }

    .signature-card {
        padding: 9px;
        border-radius: 22px;
    }

    .signature-card-image {
        border-radius: 16px;
    }
}

/* Tablet portrait */
@media (min-width: 621px) and (max-width: 820px) {
    .container,
    .flash {
        width: calc(100% - 36px);
    }

    .nav-wrap {
        min-height: 70px;
        gap: 12px;
    }

    .brand img,
    .brand.compact img {
        width: 42px;
        height: 42px;
        border-radius: 12px;
    }

    .brand-with-text {
        gap: 9px;
    }

    .brand-copy strong,
    .site-header .brand-copy strong {
        font-size: 1rem;
    }

    .main-nav {
        gap: 2px;
        flex-wrap: nowrap;
    }

    .main-nav a {
        min-height: 40px;
        padding: 8px 9px;
        font-size: .78rem;
        white-space: nowrap;
    }

    .product-grid,
    .admin-product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .signature-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .section-head {
        gap: 16px;
    }

    .section h2 {
        font-size: clamp(2rem, 4.2vw, 2.7rem);
    }

    .admin-shell {
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .sidebar {
        width: 82px;
        padding: 18px 9px;
    }

    .admin-main {
        min-width: 0;
        padding: 22px 17px 40px;
    }

    .admin-topbar h1 {
        font-size: clamp(2rem, 4.5vw, 2.8rem);
    }

    .stats-grid,
    .dashboard-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-card,
    .dashboard-stat-card {
        min-width: 0;
    }

    .admin-grid-two {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Smartphone */
@media (max-width: 620px) {
    .container,
    .success-page,
    .receipt-success-page {
        width: calc(100% - 28px);
    }

    .flash {
        width: calc(100% - 28px);
        margin-top: 12px;
        padding: 11px 13px;
        font-size: .88rem;
    }

    /* Customer header: brand on the first row, navigation below */
    .site-header {
        position: sticky;
        top: 0;
    }

    .nav-wrap {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: center;
        gap: 9px;
        min-height: 0;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .brand,
    .brand-with-text {
        align-self: flex-start;
        max-width: 100%;
        gap: 9px;
    }

    .brand img,
    .brand.compact img {
        width: 38px;
        height: 38px;
        border-radius: 11px;
    }

    .brand-copy {
        gap: 0;
        white-space: normal;
    }

    .brand-copy strong,
    .site-header .brand-copy strong {
        font-size: .98rem;
        line-height: 1.15;
    }

    .main-nav {
        display: grid;
        width: 100%;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 7px;
        justify-content: stretch;
        overflow: visible;
    }

    .main-nav a {
        width: 100%;
        min-width: 0;
        min-height: 40px;
        padding: 8px 6px;
        border-radius: 13px;
        font-size: .78rem;
        white-space: nowrap;
    }

    .main-nav .nav-admin {
        display: inline-flex;
    }

    .cart-link {
        gap: 5px;
    }

    .cart-badge {
        min-width: 19px;
        height: 19px;
        padding-inline: 5px;
        font-size: .65rem;
    }

    /* Homepage hero */
    .hero {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
        min-height: 0;
        padding: 38px 0 24px;
    }

    .hero-copy {
        width: 100%;
    }

    .hero h1 {
        margin: 14px 0;
        font-size: clamp(2.8rem, 14.5vw, 4.2rem);
        line-height: .98;
        letter-spacing: -.06em;
    }

    .hero-copy > p {
        max-width: 100%;
        margin-top: 16px;
        font-size: .94rem;
        line-height: 1.65;
    }

    .hero-actions {
        gap: 10px;
        margin-top: 20px;
    }

    .hero-art {
        width: 100%;
        min-height: clamp(280px, 82vw, 370px);
        max-width: 470px;
        margin: 5px auto 0;
    }

    .hero-art:before {
        width: 82%;
        height: 76%;
        right: 4%;
        top: 12%;
    }

    .hero-card {
        width: 69%;
        padding: 7px;
        border-radius: 20px;
    }

    .hero-card img {
        width: 100%;
        height: clamp(215px, 62vw, 275px);
        border-radius: 14px;
    }

    .hero-card-front {
        left: 1%;
        top: 24px;
    }

    .hero-card-back {
        right: 1%;
        top: 70px;
    }

    .stamp {
        width: 72px;
        height: 72px;
        top: 4px;
        right: 0;
        border-width: 1px;
        font-size: .66rem;
    }

    /* Quote strip */
    .quote-inner {
        min-height: 176px;
        gap: 9px;
        padding: 24px 4px;
    }

    .quote-inner span {
        flex: 0 0 auto;
        font-size: 2.7rem;
    }

    .quote-inner p {
        max-width: 100%;
        font-size: clamp(1.2rem, 5.5vw, 1.55rem);
        line-height: 1.25;
    }

    /* Section headings and signature cards */
    .section {
        padding: 42px 0;
    }

    .signature-section {
        padding-top: 34px;
        padding-bottom: 48px;
    }

    .section-head {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 19px;
    }

    .section h2,
    .mini-story h2,
    .panel h2 {
        font-size: clamp(1.9rem, 9vw, 2.55rem);
        line-height: 1.04;
    }

    .section-head .text-link {
        align-self: flex-start;
        font-size: .86rem;
    }

    .signature-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 13px;
    }

    .signature-card {
        padding: 9px;
        border-radius: 22px;
    }

    .signature-card-image {
        border-radius: 16px;
    }

    .site-footer {
        margin-top: 0;
        padding: 34px 0 18px;
    }

    .footer-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 22px;
    }

    .footer-grid p {
        max-width: 100%;
        font-size: .9rem;
    }

    .footer-bottom {
        margin-top: 24px;
        padding-top: 13px;
    }

    /* Generic page headings */
    .page-hero {
        padding: 38px 0 20px;
    }

    .page-hero h1 {
        margin: 13px 0 10px;
        font-size: clamp(2.65rem, 13vw, 4rem);
        line-height: 1;
    }

    .page-hero p {
        font-size: .94rem;
        line-height: 1.6;
    }

    .menu-section {
        padding-bottom: 48px;
    }

    .product-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .product-card {
        padding: 9px;
        border-radius: 21px;
    }

    .product-image-wrap {
        border-radius: 15px;
    }

    .product-info {
        gap: 10px;
        padding: 14px 3px 8px;
    }

    .product-info h3 {
        font-size: 1.25rem;
    }

    .product-info p {
        font-size: .82rem;
    }

    .card-meta {
        padding: 6px 3px 12px;
        font-size: .72rem;
    }

    .add-form {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 9px;
    }

    .add-form .btn {
        flex: 1;
        min-width: 0;
        padding-inline: 12px;
    }

    /* Cart and checkout */
    .cart-layout,
    .checkout-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
        padding-bottom: 48px;
    }

    .cart-card,
    .summary-card,
    .form-card,
    .success-card,
    .panel {
        border-radius: 20px;
    }

    .cart-card {
        padding: 5px 13px 13px;
    }

    .cart-row {
        grid-template-columns: 23px 64px minmax(0, 1fr) 36px;
        gap: 8px 9px;
        padding: 14px 0;
    }

    .cart-check {
        grid-column: 1;
        grid-row: 1;
    }

    .cart-thumb {
        grid-column: 2;
        grid-row: 1;
        width: 64px;
        height: 64px;
        border-radius: 13px;
    }

    .cart-item-copy {
        grid-column: 3;
        grid-row: 1;
        overflow-wrap: anywhere;
    }

    .cart-item-copy strong {
        font-size: .98rem;
    }

    .cart-item-copy span,
    .cart-item-copy small {
        font-size: .73rem;
    }

    .qty-stepper {
        grid-column: 2 / 4;
        grid-row: 2;
        justify-self: start;
    }

    .line-total {
        grid-column: 2 / 4;
        grid-row: 2;
        grid-row: 2;
        justify-self: end;
        align-self: center;
        font-size: .83rem;
    }

    .cart-row > .icon-btn {
        grid-column: 4;
        grid-row: 1 / 3;
        align-self: center;
    }

    .summary-card {
        position: static !important;
        padding: 17px;
    }

    .form-card {
        padding: 17px;
    }

    .checkout-form {
        gap: 17px;
    }

    .form-subhead {
        margin-top: 13px;
        font-size: 1.12rem;
    }

    .field-grid,
    .choice-grid,
    .choice-grid.three {
        grid-template-columns: minmax(0, 1fr);
        gap: 11px;
    }

    .field-grid input,
    .field-grid select,
    .field-grid textarea,
    .form-card input,
    .form-card select,
    .form-card textarea {
        min-width: 0;
        width: 100%;
        font-size: 16px;
    }

    .choice-grid .choice span,
    .choice-grid.payment-grid .choice span,
    .choice-grid[aria-label="Payment method"] .choice span {
        width: 100%;
        height: auto;
        min-height: 88px;
        padding: 15px;
    }

    .qris-panel {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
    }

    .qris-image-link {
        align-self: flex-start;
        max-width: 100%;
    }

    .qris-panel img {
        display: block;
        width: min(220px, 100%);
        max-width: 100%;
    }

    .form-actions {
        flex-direction: column-reverse;
        gap: 9px;
    }

    .form-actions .btn,
    .checkout-form > .btn,
    .auth-form .btn {
        width: 100%;
    }

    .success-page {
        padding: 42px 0 56px;
    }

    .success-card {
        grid-template-columns: minmax(0, 1fr);
        padding: 17px;
    }

    .success-card > div + div {
        border-left: 0;
        border-top: 1px solid var(--line);
        margin-top: 13px;
        padding-top: 13px;
    }

    .success-items {
        padding-inline: 13px;
    }

    .success-items div {
        gap: 10px;
        align-items: flex-start;
    }

    /* Admin shell: compact top navigation instead of a fixed sidebar */
    .admin-shell {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    .sidebar {
        position: static;
        inset: auto;
        width: 100%;
        padding: 12px 14px 9px;
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, .1);
    }

    .admin-brand {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 0 2px 10px;
    }

    .admin-brand-row {
        width: auto;
        gap: 9px;
    }

    .admin-brand img {
        width: 39px;
        height: 39px;
        border-radius: 11px;
    }

    .admin-brand-copy {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }

    .admin-brand-copy strong {
        font-size: .83rem;
    }

    .admin-workspace {
        display: none;
    }

    .admin-nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        width: 100%;
        padding: 0 0 3px;
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .admin-nav::-webkit-scrollbar {
        display: none;
    }

    .side-link {
        display: inline-flex;
        flex: 0 0 auto;
        width: auto;
        min-width: max-content;
        min-height: 42px;
        justify-content: flex-start;
        gap: 7px;
        padding: 7px 10px;
        border-radius: 13px;
        font-size: .78rem;
    }

    .side-link span:not(.side-link-icon) {
        display: inline;
    }

    .side-link-icon {
        width: 27px;
        height: 27px;
        border-radius: 9px;
        font-size: .82rem;
    }

    .sidebar-bottom {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        margin-top: 7px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-bottom::-webkit-scrollbar {
        display: none;
    }

    .sidebar-bottom form {
        flex: 0 0 auto;
        margin: 0;
    }

    .sidebar-bottom .side-link {
        font-size: .76rem;
    }

    .admin-main {
        grid-column: auto;
        width: 100%;
        min-width: 0;
        padding: 17px 14px 36px;
    }

    .admin-topbar {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 19px;
    }

    .admin-topbar h1 {
        margin-top: 7px;
        font-size: clamp(2rem, 10vw, 2.75rem);
        overflow-wrap: anywhere;
    }

    .admin-user {
        max-width: 100%;
        padding: 6px 12px 6px 6px;
    }

    .admin-user strong {
        overflow-wrap: anywhere;
    }

    .admin-actions {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .admin-actions > .btn,
    .admin-products-actions > .btn {
        width: 100%;
    }

    .admin-filters,
    .filter-row {
        display: flex;
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 6px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .admin-filters::-webkit-scrollbar,
    .filter-row::-webkit-scrollbar {
        display: none;
    }

    .filter {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .search-box,
    .admin-product-search {
        width: 100%;
        min-width: 0;
    }

    .admin-grid-two {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .stats-grid,
    .dashboard-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card,
    .dashboard-stat-card {
        min-width: 0;
        min-height: 116px;
        padding: 13px;
        border-radius: 17px;
    }

    .stat-card strong,
    .dashboard-stat-card strong {
        font-size: clamp(1.08rem, 5vw, 1.55rem);
        line-height: 1.15;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .stat-card span,
    .stat-card small,
    .dashboard-stat-card span,
    .dashboard-stat-card small {
        font-size: .68rem;
    }

    .dashboard-recent-orders,
    .panel {
        padding: 15px;
        border-radius: 18px;
    }

    .panel-head {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 9px;
    }

    .panel h2 {
        font-size: 1.65rem;
    }

    .table-wrap,
    .report-table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrap table,
    .report-table-wrap table {
        min-width: 650px;
    }

    .admin-product-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 13px;
    }

    .admin-product-img {
        height: clamp(180px, 58vw, 250px);
    }

    .admin-form .field-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        min-width: 0;
    }

    .admin-form .field-grid > * {
        min-width: 0;
    }

    .admin-form input,
    .admin-form select,
    .admin-form textarea {
        width: 100%;
        min-width: 0;
        font-size: 16px;
    }

    .admin-table-actions {
        min-width: 190px;
    }

    .report-filter-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .report-filter-actions,
    .report-filter-actions .btn {
        width: 100%;
    }

    .report-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 13px;
    }

    .report-download-buttons {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
    }

    .report-download-buttons .btn {
        flex: 1 1 130px;
        min-width: 0;
    }

    .detail-top {
        align-items: flex-start;
        flex-direction: column;
        gap: 9px;
    }

    .detail-total {
        text-align: left;
    }

    /* Login and receipt pages */
    .auth-page {
        min-height: 100vh;
        padding: 26px 0;
    }

    .minimal-main .auth-page {
        min-height: 100vh;
        padding: 64px 0 28px;
    }

    .auth-card {
        width: 100%;
        padding: 23px 18px;
        border-radius: 21px;
    }

    .auth-card h1 {
        font-size: clamp(2.5rem, 12vw, 3.5rem);
    }

    .back-to-store {
        top: 12px;
        left: 14px;
    }

    .receipt-success-page {
        padding: 28px 0 42px;
    }

    .receipt-success-page h1 {
        margin-bottom: 24px;
        font-size: clamp(2.45rem, 12vw, 3.8rem);
        overflow-wrap: anywhere;
    }

    .receipt-section-head .lead {
        font-size: .9rem;
    }

    .receipt-preview-card,
    .receipt-image-frame {
        width: 100%;
        max-width: 100%;
    }

    .receipt-image {
        display: block;
        width: 100%;
        height: auto;
    }

    .receipt-page-actions {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .receipt-page-actions .btn {
        width: 100%;
    }
}

/* Compact smartphones */
@media (max-width: 390px) {
    .container,
    .success-page,
    .receipt-success-page {
        width: calc(100% - 24px);
    }

    .main-nav {
        gap: 5px;
    }

    .main-nav a {
        padding-inline: 3px;
        font-size: .7rem;
    }

    .hero h1 {
        font-size: clamp(2.65rem, 14vw, 3.5rem);
    }

    .hero-art {
        min-height: 285px;
    }

    .hero-card img {
        height: 215px;
    }

    .stamp {
        width: 64px;
        height: 64px;
        font-size: .59rem;
    }

    .cart-row {
        grid-template-columns: 21px 56px minmax(0, 1fr) 32px;
        gap: 7px;
    }

    .cart-thumb {
        width: 56px;
        height: 56px;
    }

    .cart-item-copy strong {
        font-size: .9rem;
    }

    .qty-stepper {
        transform: scale(.94);
        transform-origin: left center;
    }

    .stats-grid,
    .dashboard-stats {
        grid-template-columns: minmax(0, 1fr);
    }

    .stat-card,
    .dashboard-stat-card {
        min-height: 104px;
    }

    .admin-main {
        padding-inline: 12px;
    }

    .sidebar {
        padding-inline: 12px;
    }

    .admin-brand-copy {
        max-width: calc(100vw - 90px);
    }
}

/* Wide tables remain usable on touch screens without breaking page width. */
.table-wrap,
.report-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrap table,
.report-table-wrap table {
    max-width: none;
}

/* Prevent long customer/product values from stretching cards. */
.product-info,
.cart-item-copy,
.admin-product-body,
.detail-item,
.report-item-line,
.panel-head,
.admin-topbar > div {
    min-width: 0;
}

.product-info h3,
.product-info p,
.cart-item-copy strong,
.admin-product-body h3,
.admin-product-body p,
td,
th {
    overflow-wrap: anywhere;
}

/* Respect reduced-motion preferences on devices that request it. */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
