@layer reset, base, layout, components, pages, utilities;

/* Your recipes: cookbooks at the top, recently added, tiles for types and folders, folder pages. */
@layer pages {
  .page-title__count { font: 500 22px var(--sans); color: var(--muted); letter-spacing: 0; }
  .section-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 15px; text-decoration: none; }
  .library-section { display: flex; flex-direction: column; gap: 14px; }

  .chip--sm { height: 22px; padding: 0 9px; font-size: 12px; font-weight: 600; }
  .chip--accent { background: var(--accent-soft); color: var(--accent-ink); }

  /* Your cookbooks -------------------------------------------------------- */

  .cookbook-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
  .cookbook-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    text-decoration: none;
  }
  .cookbook-card:hover { color: var(--ink); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
  .cookbook-card__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
  .cookbook-card__title { font: 500 21px/1.15 var(--serif); }
  .cookbook-card__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
  .cookbook-card__go { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--accent); white-space: nowrap; }
  .cookbook-card--new { border-style: dashed; border-color: var(--dashed); background: transparent; }
  .cookbook-card__plus {
    width: 64px;
    height: 84px;
    flex-shrink: 0;
    border-radius: 4px 8px 8px 4px;
    border: 1.5px dashed var(--dashed);
    display: grid;
    place-items: center;
    color: var(--muted);
  }

  .cookbook-cover {
    width: 64px;
    height: 84px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 3px 7px 7px 3px;
    border-left: 4px solid color-mix(in srgb, var(--cover) 70%, black);
    background: var(--cover);
    box-shadow: 3px 5px 12px rgba(35, 30, 25, .22);
  }
  .cookbook-cover__front { display: block; width: 100%; height: 100%; object-fit: cover; }
  .cookbook-cover__photo { display: block; width: 100%; height: 58%; object-fit: cover; background: #B98A7A; flex-shrink: 0; }
  .cookbook-cover__title {
    padding: 4px 5px;
    color: #fff;
    font: 500 9px/1.1 var(--serif);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }
  .cookbook-cover__title--foil { margin: auto 0; text-align: center; color: var(--foil); font-size: 10px; }

  /* Recently added: one row ---------------------------------------------- */

  @media (min-width: 901px) and (max-width: 1200px) {
    .recipe-grid--row > :nth-child(n + 4) { display: none; }
  }

  /* Tiles for dish types and folders -------------------------------------- */

  .tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .tile { position: relative; border-radius: var(--radius-xl); overflow: hidden; aspect-ratio: 1; background: var(--sunken); }
  .tile--folder { aspect-ratio: 4 / 3; }
  .tile__link { position: absolute; inset: 0; display: block; color: #fff; text-decoration: none; }
  .tile__link:hover { color: #fff; }
  .tile__link:focus-visible { outline: 3px solid var(--ink); outline-offset: -3px; }
  .tile__art { position: absolute; inset: 0; display: grid; gap: 2px; background: var(--border); }
  .tile__art--2 { grid-template-columns: 1fr 1fr; }
  .tile__art--3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
  .tile__art--3 > :first-child { grid-row: span 2; }
  .tile__art--4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
  .tile__art .media { min-height: 0; }
  .tile__art .media__plate { width: 48%; }
  .tile__plate { background: var(--plate, #D9A873); }
  .tile__link:hover .tile__art img { transform: scale(1.03); }
  .tile__art img { transition: transform .2s; }
  .tile__label {
    position: absolute;
    inset: auto 0 0 0;
    padding: 36px 16px 14px;
    background: linear-gradient(transparent, rgba(35, 30, 25, .82));
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 14px;
  }
  .tile__label b { font: 500 24px/1.1 var(--serif); }
  .tile__change {
    position: absolute;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 253, 248, .92);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    opacity: 0;
    transition: opacity .15s;
  }
  .tile:hover .tile__change, .tile__change:focus-visible { opacity: 1; }

  .new-folder { position: relative; }
  .new-folder > summary { list-style: none; }
  .new-folder > summary::-webkit-details-marker { display: none; }
  .new-folder__form {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 30;
    display: flex;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .new-folder__form input, .folder-menu__form input {
    min-width: 0;
    width: 220px;
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font-size: 15px;
  }

  /* Narrowing a dish type by its tags ------------------------------------- */

  .filter-chips--tags { align-items: center; }
  .filter-chips__label { font-size: 13px; font-weight: 600; color: var(--muted); margin-right: 2px; }
  .filter-chip--sm { height: 32px; padding: 0 12px; font-size: 13px; }
  .filter-chips__clear { font-size: 14px; font-weight: 600; margin-left: 4px; }

  /* Folder pages ---------------------------------------------------------- */

  .folder-menu > summary { gap: 8px; }
  .folder-menu .menu__items { min-width: 260px; }
  .menu__note { padding: 6px 12px 8px; font-size: 13px; line-height: 1.4; color: var(--muted); }
  .menu__items .menu__danger { color: var(--accent); }
  .folder-menu__rename > summary {
    padding: 10px 12px;
    border-radius: 8px;
    font: 500 14px var(--sans);
    list-style: none;
    cursor: pointer;
  }
  .folder-menu__rename > summary::-webkit-details-marker { display: none; }
  .folder-menu__rename > summary:hover { background: var(--sunken); }
  .folder-menu__form { display: flex; gap: 6px; padding: 0 8px 8px; }
  .folder-menu__form input { width: auto; flex: 1; }
  .menu__items .folder-menu__form .btn { width: auto; padding: 0 12px; color: var(--surface); text-align: center; }

  .recipe-card-wrap { position: relative; display: flex; flex-direction: column; }
  .recipe-card-wrap > .recipe-card { flex-grow: 1; }
  .recipe-card-wrap form { position: absolute; top: 10px; right: 10px; z-index: 2; margin: 0; }
  .recipe-card__remove {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 253, 248, .94);
    color: var(--ink);
    font: 600 13px var(--sans);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
  }
  .recipe-card-wrap:hover .recipe-card__remove, .recipe-card__remove:focus-visible { opacity: 1; }
  .recipe-card__remove:hover { background: var(--surface); border-color: var(--ink-3); }
  .recipe-card-wrap .badge-fav, .recipe-card-wrap .badge-new { display: none; }

  /* Touch screens have no hover, so these are always showing there: the picture button as just its icon. */
  @media (hover: none) {
    .tile__change, .recipe-card__remove { opacity: 1; }
    .tile .tile__change { width: 34px; padding: 0; justify-content: center; }
    .tile__change-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  }

  .empty-folder p { max-width: 520px; }

  /* Change picture -------------------------------------------------------- */

  .picture-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; border: 0; padding: 0; margin: 0; }
  .picture-picker__item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-lg);
    border: 2px solid transparent;
    background: var(--surface);
    cursor: pointer;
  }
  .picture-picker__item .media { aspect-ratio: 1; height: auto; border-radius: var(--radius); overflow: hidden; }
  .picture-picker__item:has(input:checked) { border-color: var(--accent); }
  .picture-picker__item:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
  .picture-picker__title { font: 500 16px/1.2 var(--serif); }

  /* Navigation: the imports count and the More page's cookbooks ------------ */

  .nav__note { margin-left: auto; font-size: 13px; color: var(--accent-ink); font-weight: 600; }
  .nav__note + .nav__count { margin-left: 0; }
  .nav a.menu-cookbook { min-height: 72px; gap: 14px; padding: 8px 12px; }
  .menu-cookbook .cookbook-cover { width: 40px; height: 52px; border-left-width: 3px; }
  .menu-cookbook .cookbook-cover__title { display: none; }
  .menu-cookbook .cookbook-cover__photo { height: 100%; }
  .menu-cookbook__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .menu-cookbook__text b { font: 500 18px/1.2 var(--serif); color: var(--ink); }
  .menu-cookbook__text span { font-size: 13px; color: var(--muted); }
  .menu-cookbook__go { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 600; color: var(--accent); }

  @media (max-width: 1200px) {
    .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }

  @media (max-width: 900px) {
    .page-title__count { font-size: 18px; }
    .cookbook-cards { grid-template-columns: minmax(0, 1fr); }
    .cookbook-card { padding: 10px; }
    .cookbook-card__go { font-size: 14px; }
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .tile { border-radius: var(--radius-lg); }
    .tile__label { padding: 30px 12px 10px; }
    .tile__label b { font-size: 19px; }
    .tile__change { top: 8px; right: 8px; min-height: 30px; padding: 0 10px; font-size: 12px; }
    .new-folder__form { position: fixed; inset: auto 16px auto 16px; top: 120px; }
    .new-folder__form input { flex: 1; width: auto; }
    .folder-menu .menu__items { right: auto; left: 0; }
    .folder-share { padding: 0 14px; }
    .folder-share__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .filter-chips--tags .filter-chips__label { flex-shrink: 0; }
  }
}
