/* Focused storefront accessibility layer. Kept unminified and served directly. */
:root {
    --store-text-scale: 1;
}
[data-store-text] {
    /* Legacy transition: all must not animate the measurement baseline. */
    transition-property: color, background-color, border-color, opacity, transform !important;
}
html[data-text-size-measuring] body * {
    transition: none !important;
}
html[data-text-size="large"] { --store-text-scale: 1.125; }
html[data-text-size="extra-large"] { --store-text-scale: 1.25; }

/* Absolute measured baselines also cover legacy px and inline typography.
   No zoom, transforms, root rem changes, or image/reader sizing changes. */
html[data-text-size="large"] [data-store-text],
html[data-text-size="extra-large"] [data-store-text] {
    font-size: calc(var(--store-text-font) * var(--store-text-scale)) !important;
    line-height: calc(var(--store-text-leading) * var(--store-text-scale)) !important;
}
html[data-text-size="large"] [data-store-text]:not(input):not(select):not(textarea),
html[data-text-size="extra-large"] [data-store-text]:not(input):not(select):not(textarea) {
    overflow-wrap: anywhere;
}
html[data-text-size="large"] button[data-store-text],
html[data-text-size="extra-large"] button[data-store-text] {
    height: auto;
    min-height: 44px;
    white-space: normal;
}

.header-display-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}
.text-size-control {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 14px;
    line-height: 1.5;
}
.text-size-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border: 1px solid #59616b;
    border-radius: 6px;
    background: transparent;
    color: #f5ede3;
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}
.text-size-toggle:hover,
.text-size-toggle[aria-expanded="true"] {
    border-color: #ffb84d;
    color: #ffb84d;
    background: #2c241b;
}
.text-size-control button:focus-visible {
    outline: 2px solid #ffb84d;
    outline-offset: 3px;
}
.text-size-panel {
    position: absolute;
    z-index: 1100;
    inset: calc(100% + 8px) 0 auto auto;
    width: 220px;
    max-width: calc(100vw - 24px);
    padding: 12px;
    border: 1px solid #b97327;
    border-radius: 10px;
    background: #faf5ef;
    color: #292018;
    box-shadow: 0 8px 24px rgba(19, 25, 33, .22);
}
.text-size-panel[hidden] { display: none !important; }
.text-size-label {
    margin: 0 4px 8px;
    font-size: 13px;
    font-weight: 700;
}
.text-size-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    white-space: normal;
    cursor: pointer;
}
.text-size-option span:last-child { font-size: 12px; }
.text-size-option:hover { background: #f4e4d0; }
.text-size-option[aria-pressed="true"] {
    background: #ff9900;
    color: #131921;
    border-color: #a95408;
    font-weight: 700;
}
body.dark .text-size-panel {
    background: #191c20;
    color: #f5ede3;
    border-color: #a66a2d;
}
body.dark .text-size-option:hover { background: #35291d; }
body.dark .text-size-option[aria-pressed="true"] {
    background: #ff9900;
    color: #131921;
}

/* Leave the search room to shrink; long account names must not evict controls. */
.main-header .header-content { gap: 12px; }
.main-header .search-container,
.main-header .search-form input { min-width: 0; }
.main-header .header-nav { align-items: center; flex-shrink: 0; }
.main-header .account-name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (min-width: 1201px) and (max-width: 1599px) {
    .main-header .header-nav a.hdr-reader { display: none; }
    .main-header .header-nav a { padding-inline: 6px; }
}
@media (min-width: 1201px) and (max-width: 1399px) {
    .main-header .header-nav a.hdr-bestseller,
    .main-header .header-nav a.hdr-sale { display: none; }
}
/* Enlarged navigation needs the drawer earlier than normal typography. */
@media (min-width: 1201px) and (max-width: 1599px) {
    html:not([data-text-size="normal"]) .main-header .header-nav a.hdr-bestseller,
    html:not([data-text-size="normal"]) .main-header .header-nav a.hdr-sale {
        display: none;
    }
}
@media (max-width: 1200px) {
    .main-header .header-nav { display: none; }
    .main-header .mobile-menu-toggle { display: flex; }
    .main-header .mobile-cart-link { display: inline-flex !important; }
    .main-header .logo { display: none !important; }
    .main-header .search-container { flex: 1; max-width: none; }
    .main-header .header-display-controls { margin-left: auto; }
    .main-header .header-content { gap: 8px; }
}
@media (max-width: 768px) {
    .main-header .header-content { flex-wrap: wrap; }
    .main-header .search-container {
        order: 3;
        flex: 1 1 100%;
        margin-top: 4px;
    }
    .main-header .search-form,
    .main-header .search-form input {
        height: auto;
        min-height: 44px;
        line-height: 1.5;
    }
    .main-header .search-form button { height: auto; }
    .main-header .mobile-cart-link { margin-left: auto; }
    .main-header .header-display-controls { margin-left: 0; }
}
.header-display-controls .dark-mode-toggle,
.checkout-header-right .checkout-theme-toggle,
.checkout-header-right #checkout-theme-toggle {
    display: flex;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
}

/* Do not clip checkout copy or force payment controls wider than their card. */
.checkout-page .checkout-header-content {
    flex-wrap: wrap;
    gap: 12px;
}
.checkout-page .checkout-header-right { gap: 8px; }
.checkout-page .checkout-main,
.checkout-page .checkout-sidebar,
.checkout-page .step-info,
.checkout-page .input-wrapper,
.checkout-page .checkout-coupon-input-wrap { min-width: 0; }
html:not([data-text-size="normal"]) .checkout-page button,
html:not([data-text-size="normal"]) .checkout-page button span {
    white-space: normal;
    height: auto;
}
html:not([data-text-size="normal"]) .checkout-page .total-line,
html:not([data-text-size="normal"]) .checkout-page .order-total-final,
html:not([data-text-size="normal"]) .checkout-page .cart-item-formats,
html:not([data-text-size="normal"]) .checkout-page .checkout-coupon-form {
    flex-wrap: wrap;
    gap: 8px;
}
html:not([data-text-size="normal"]) .checkout-page input:not([type="checkbox"]):not([type="radio"]),
html:not([data-text-size="normal"]) .checkout-page select {
    max-width: 100%;
    min-width: 0;
    height: auto;
    min-height: 44px;
}
@media (max-width: 600px) {
    .checkout-page .checkout-header-content { padding-inline: 16px; }
    .checkout-page .checkout-header-steps {
        order: 3;
        flex-basis: 100%;
        justify-content: center;
    }
    .checkout-page .checkout-header-right { margin-left: auto; }
    .checkout-page .cart-item { flex-wrap: wrap; }
    .checkout-page .cart-item-details { flex-basis: calc(100% - 100px); }
    .checkout-page .cart-item-price {
        margin-left: 0;
        max-width: 100%;
        flex-wrap: wrap;
    }
}
/* Learning content can grow without losing the ends of commands or controls. */
html:not([data-text-size="normal"]) .lh-article { min-width: 0; }
html:not([data-text-size="normal"]) .lh-article pre { overflow-x: auto; }
html:not([data-text-size="normal"]) :is(.btn, .book-card-title, .book-card-description) {
    height: auto;
    max-height: none;
    white-space: normal;
    -webkit-line-clamp: unset;
}
/* Existing intrinsic grid minimums otherwise overflow even at Normal. */
body .ds-signup-copy,
body .ds-signup-actions,
body .pfb-card { min-width: 0; }
body .pfb-covers { flex-wrap: wrap; }
@media (max-width: 600px) {
    body .ds-signup { grid-template-columns: minmax(0, 1fr); }
    body .ds-signup-form { flex-wrap: wrap; }
    body .ds-signup-form input { flex-basis: 100%; width: 100%; }
    body .ds-signup-form button { width: 100%; white-space: normal; }
}
@media (max-width: 768px) {
    /* Match the catalog's actual 10px mobile gutter, not the older 14px rail. */
    body .quick-chips,
    body .browse-rail-track { margin-inline: -10px; }
}
