/* общее */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: #f5f5f5;
    color: #d1d1d1;
    line-height: 2;
    padding-top: 4.5rem;
}

/* шапка */
header {
    position: fixed;
    background-color: #2a2f3a;
    padding: 1rem 2rem;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

header nav {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* логотип */
.logo {
    font-size: clamp(1rem, 5vw, 1.5rem);
    font-weight: 700;
    text-decoration: none;
    color: #f5f5f5;
    letter-spacing: 1px;
}

/* меню навигации */
nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
}

nav a {
    font-size: clamp(0.75rem, 3vw, 1rem);
    text-decoration: none;
    color: #a0a5b0;
    font-weight: 500;
    transition: color 0.3s ease;
}
nav a:hover {
    color: #f5f5f5;
}

/* корзина кнопка в шапке */
.cart-button {
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    color: #2c3e50;
    display: flex;
    align-items: center;
}

.cart-button svg {
    width: 32px;
    height: 32px;
}

.cart-count {
    position: absolute;
    top: -6px;
    right: -10px;
    background: #4a90e2;
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 9999px;
}

.cart-count {
    position: absolute;
    top: -6px;
    right: -10px;
    background: #4a90e2; 
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 9999px;
}

/* основа */
main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* карточки товаров и сетка */
.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.product-card {
    background: #2a2f3a; 
    border-radius: 30px; 
    box-shadow: 0 20px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.product-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

.product-description {
    font-size: 0.85rem;
    color: #b0b3b8;
    margin: 0rem 1.5rem;
    line-height: 1.4;
    text-align: justify;
    flex-grow: 1; 
}

.product-link {
    display: block;
    text-align: center;
    padding: 2rem 1rem 1rem; 
}

.product-card img {
    max-width: 90%;
    width: 24rem;
    height: auto;
    border-radius: 16px;
    object-fit: cover;
}

.product-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e0e0e0;
}

.product-price {
    font-size: 1.2rem;
    color: #b0b3b8;
    font-weight: 600;
    color: #e0e0e0;
    text-align: right;
    margin: 0 1.8rem;
    margin-top: auto;
}

/* добавление товара в корзину */
.add-to-cart {
    margin: 1rem;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 600;
    background: #3b4455;
    color: #e0e0e0;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    margin-top: auto;
}
.add-to-cart:hover {
    background: #505a6b;
    transform: translateY(-2px);
}

/* корзина (панель) */
.cart-panel {
    position: fixed;
    top: 70px;
    right: 0;
    width: 460px;
    background: #f9f9f9; 
    color: #2a2f3a; 
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    padding: 2rem 1.5rem;
    z-index: 1000;
    border-radius: 0 0 0 20px;
    transform: translateX(100%);
    display: flex;
    flex-direction: column;
    height: calc(100% - 70px);
    transition: transform 0.3s ease;
}
.cart-panel.open {
    transform: translateX(0);
}

#checkout-button {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
    font-weight: 600;
    background: #3b4455;
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s ease;
}
#checkout-button:hover {
    background: #505a6b;
}

.cart-item .cart-item-qty {
    grid-area: qty;
    font-size: 0.9rem;
    text-align: right;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.cart-summary {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* карточка товара в корзине */
.cart-item {
    background-color: #2a2f3a;
    color: #e0e0e0;
    padding: 1.2rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    display: grid;
    grid-template-columns: 2fr 1fr auto 1fr auto;
    grid-template-areas:
        "name qty"
        "remove total";
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: start;
}

/* название товара */
.cart-item .cart-item-name {
    grid-area: name;
    font-weight: normal;
    font-size: 1rem;
    text-align: left;
}

/* количество товара */
.cart-item .cart-item-controls {
    grid-area: qty;
    display: flex;
    align-items: center;
    gap: 5px;
}
.cart-item .cart-item-controls button {
    padding: 2px 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* кнопка удаления */
.cart-item .cart-item-remove {
    grid-area: remove;
    background: none;
    border: none;
    color: #d1d1d1;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
    align-self: end; 
    justify-self: start; 
}
.cart-item .cart-item-remove:hover {
    color: #fff;
}

/* итоговая сумма */
.cart-item .cart-item-total {
    grid-area: total;
    text-align: right;
    font-weight: 600;
    color: #e0e0e0;
    align-self: end; 
    justify-self: end; 
}

/* модалки о нас и контакты */
.modal {
  width: 90%;
  max-width: 500px;
  border: none;
  border-radius: 16px;
  padding: 1.5rem;
  background: #2a2f3a;
  color: #e0e0e0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

dialog {
  border: none;
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  text-align: center;

  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

dialog::backdrop {
  background: rgba(0,0,0,0.5);
}

dialog h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

dialog p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 1rem;
    text-align: justify; 
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

main.cart-open {
    margin-right: calc(460px + 1.5rem); 
    transition: margin-right 0.3s ease;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; 
    margin: 0 0 2rem 0;
}

.close-cart {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #2a2f3a;
    transition: color 0.2s ease;
    margin-top: 0.3rem; 
}
.close-cart:hover {
    color: #ff4c4c;
}

.copy-text {
    cursor: pointer;
    color: #4a90e2;
    text-decoration: underline;
}
.copy-text:hover {
    color: #357ABD;
}

/* модалка оформления заказа */
.order-modal {
    width: 90%;
    max-width: 500px;
    border: none;
    border-radius: 16px;
    padding: 2rem;
    background: #ffffff;
    color: #2a2f3a; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: left;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
}

.order-modal header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-modal h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.order-modal .modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #2a2f3a;
}

#order-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

#order-form label {
    display: flex;
    flex-direction: column;
    font-weight: 500;
    font-size: 1rem;
}

#order-form input {
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    margin-top: 0.3rem;
}

#order-form button[type="submit"] {
    padding: 0.85rem;
    background: #2a2f3a;
    color: #ffffff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: background 0.3s ease;
}
#order-form button[type="submit"]:hover {
    background: #505a6b;
}

/* модалка заказ создан */
#order-success-modal {
  display: none; 
  position: fixed; 
  top: 50%; 
  left: 50%;
  transform: translate(-50%, -50%); 
  background-color: #ffffff;
  color: #1a1a1a;
  font-size: 5rem; 
  font-weight: 700;
  border: none;
  border-radius: 16px;
  padding: 2rem 3rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  text-align: center;
  min-width: 300px;
  min-height: 150px;
  z-index: 1000;
}

#order-success-modal[open] {
  display: flex;
  justify-content: center;
  align-items: center;
}

#order-success-modal .modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 1.5rem; 
  cursor: pointer;
  color: #1a1a1a;
}

/* утилка для доступности */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* адаптивка под планшеты */
@media (max-width: 1200px) {
    .cart-panel {
        width: 350px;
    }

    main.cart-open {
        margin-right: calc(350px + 1.5rem);
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* адаптивка под телефоны */
@media (max-width: 930px) {
    header {
        padding: 1.2rem
    }

    .cart-header h2 {
        display: block;
        font-size: 1.2rem;
    }

    nav ul {
        gap: 1rem;
    }

    .cart-panel {
        width: 100%;
        height: 100%;
        top: 0;
        right: 0;
        border-radius: 0;
        padding-top: 5.5rem;
    }

    main.cart-open {
        margin-right: 0;
    }

    .products-grid {
        grid-template-columns: 1fr;
    }

    .logo {
        font-size: 0.9rem
    }
}